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"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { IMedia } from "@/types/media.model";
|
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-06-10 09:41:07 +02:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
LazyImage,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class LazyImageWrapper extends Vue {
|
2021-06-16 11:26:39 +02:00
|
|
|
@Prop({ required: true })
|
2021-06-29 18:38:38 +02:00
|
|
|
picture!: IMedia | null;
|
2021-06-10 09:41:07 +02:00
|
|
|
|
|
|
|
get pictureOrDefault(): Partial<IMedia> {
|
2021-06-16 11:26:39 +02:00
|
|
|
if (this.picture === null) {
|
|
|
|
return DEFAULT_PICTURE;
|
|
|
|
}
|
2021-06-10 09:41:07 +02:00
|
|
|
return {
|
2021-06-16 11:26:39 +02:00
|
|
|
url: this?.picture?.url,
|
2021-06-10 09:41:07 +02:00
|
|
|
metadata: {
|
2021-06-16 11:26:39 +02:00
|
|
|
width: this?.picture?.metadata?.width,
|
|
|
|
height: this?.picture?.metadata?.height,
|
|
|
|
blurhash: this?.picture?.metadata?.blurhash,
|
2021-06-10 09:41:07 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|