2021-06-10 09:41:07 +02:00
|
|
|
<template>
|
|
|
|
<lazy-image
|
|
|
|
v-if="pictureOrDefault.url !== undefined"
|
|
|
|
:src="pictureOrDefault.url"
|
|
|
|
:width="pictureOrDefault.metadata.width"
|
|
|
|
:height="pictureOrDefault.metadata.height"
|
|
|
|
:blurhash="pictureOrDefault.metadata.blurhash"
|
2021-11-02 19:47:54 +01:00
|
|
|
:rounded="rounded"
|
2021-06-10 09:41:07 +02:00
|
|
|
/>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from "vue";
|
2021-06-10 09:41:07 +02:00
|
|
|
import { IMedia } from "@/types/media.model";
|
|
|
|
import LazyImage from "../Image/LazyImage.vue";
|
|
|
|
|
2021-06-16 11:26:39 +02:00
|
|
|
const DEFAULT_CARD_URL = "/img/mobilizon_default_card.png";
|
|
|
|
const DEFAULT_BLURHASH = "MCHKI4El-P-U}+={R-WWoes,Iu-P=?R,xD";
|
|
|
|
const DEFAULT_WIDTH = 630;
|
|
|
|
const DEFAULT_HEIGHT = 350;
|
|
|
|
const DEFAULT_PICTURE = {
|
|
|
|
url: DEFAULT_CARD_URL,
|
|
|
|
metadata: {
|
|
|
|
width: DEFAULT_WIDTH,
|
|
|
|
height: DEFAULT_HEIGHT,
|
|
|
|
blurhash: DEFAULT_BLURHASH,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
picture?: IMedia | null;
|
|
|
|
rounded?: boolean;
|
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
rounded: false,
|
|
|
|
}
|
|
|
|
);
|
2021-06-10 09:41:07 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const pictureOrDefault = computed(() => {
|
|
|
|
if (props.picture === null) {
|
|
|
|
return DEFAULT_PICTURE;
|
2021-06-10 09:41:07 +02:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
return {
|
|
|
|
url: props?.picture?.url,
|
|
|
|
metadata: {
|
|
|
|
width: props?.picture?.metadata?.width,
|
|
|
|
height: props?.picture?.metadata?.height,
|
|
|
|
blurhash: props?.picture?.metadata?.blurhash,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
2021-06-10 09:41:07 +02:00
|
|
|
</script>
|