Refactor default image wrapper
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2779846671
commit
a765d226b8
@ -12,27 +12,38 @@ import { IMedia } from "@/types/media.model";
|
|||||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||||
import LazyImage from "../Image/LazyImage.vue";
|
import LazyImage from "../Image/LazyImage.vue";
|
||||||
|
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
LazyImage,
|
LazyImage,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class LazyImageWrapper extends Vue {
|
export default class LazyImageWrapper extends Vue {
|
||||||
@Prop({ required: true, default: null })
|
@Prop({ required: true })
|
||||||
picture!: IMedia | null;
|
picture!: IMedia;
|
||||||
|
|
||||||
get pictureOrDefault(): Partial<IMedia> {
|
get pictureOrDefault(): Partial<IMedia> {
|
||||||
|
if (this.picture === null) {
|
||||||
|
return DEFAULT_PICTURE;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
url:
|
url: this?.picture?.url,
|
||||||
this?.picture === null
|
|
||||||
? "/img/mobilizon_default_card.png"
|
|
||||||
: this?.picture?.url,
|
|
||||||
metadata: {
|
metadata: {
|
||||||
width: this?.picture?.metadata?.width || 630,
|
width: this?.picture?.metadata?.width,
|
||||||
height: this?.picture?.metadata?.height || 350,
|
height: this?.picture?.metadata?.height,
|
||||||
blurhash:
|
blurhash: this?.picture?.metadata?.blurhash,
|
||||||
this?.picture?.metadata?.blurhash ||
|
|
||||||
"MCHKI4El-P-U}+={R-WWoes,Iu-P=?R,xD",
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user