2022-04-26 23:47:10 +02:00
|
|
|
<template>
|
2022-05-09 16:31:53 +02:00
|
|
|
<div :class='{ img: true, thumb }'>
|
2022-04-26 23:47:10 +02:00
|
|
|
<img
|
|
|
|
v-if='media'
|
2022-05-09 16:31:53 +02:00
|
|
|
:class='{ "u-featured": true }'
|
2022-04-26 23:47:10 +02:00
|
|
|
:alt='media.name' :loading='lazy?"lazy":"eager"'
|
|
|
|
:src="src"
|
2022-05-03 12:08:10 +02:00
|
|
|
:srcset="srcset"
|
2022-04-26 23:47:10 +02:00
|
|
|
itemprop="image"
|
2022-04-27 11:27:08 +02:00
|
|
|
:height="height" :width="width"
|
2022-05-09 16:31:53 +02:00
|
|
|
:style="{ 'object-position': thumbnailPosition }">
|
2022-04-26 23:47:10 +02:00
|
|
|
|
2022-10-28 12:01:59 +02:00
|
|
|
<img v-else-if='!media && thumb' class='thumb' src="/fallbackimage.png" alt=''>
|
2022-05-09 16:31:53 +02:00
|
|
|
</div>
|
2022-04-26 23:47:10 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
event: { type: Object, default: () => ({}) },
|
|
|
|
thumb: { type: Boolean, default: false },
|
|
|
|
lazy: { type: Boolean, default: false },
|
|
|
|
showPreview: { type: Boolean, default: true }
|
|
|
|
},
|
|
|
|
computed: {
|
2022-04-27 11:27:08 +02:00
|
|
|
backgroundPreview () {
|
2022-04-29 17:56:34 +02:00
|
|
|
if (this.media && this.media.preview) {
|
2022-04-27 11:27:08 +02:00
|
|
|
return {
|
|
|
|
backgroundPosition: this.thumbnailPosition,
|
|
|
|
backgroundImage: "url('data:image/png;base64," + this.media.preview + "')" }
|
|
|
|
}
|
2022-04-26 23:47:10 +02:00
|
|
|
},
|
2022-05-03 12:08:10 +02:00
|
|
|
srcset () {
|
|
|
|
if (this.thumb) return ''
|
|
|
|
return `/media/thumb/${this.media.url} 500w, /media/${this.media.url} 1200w`
|
|
|
|
},
|
2022-04-26 23:47:10 +02:00
|
|
|
media () {
|
2022-05-20 12:32:51 +02:00
|
|
|
return this.event.media && this.event.media[0]
|
2022-04-26 23:47:10 +02:00
|
|
|
},
|
2022-04-27 11:27:08 +02:00
|
|
|
height () {
|
|
|
|
return this.media ? this.media.height : 'auto'
|
|
|
|
},
|
|
|
|
width () {
|
|
|
|
return this.media ? this.media.width : 'auto'
|
|
|
|
},
|
2022-04-26 23:47:10 +02:00
|
|
|
src () {
|
|
|
|
if (this.media) {
|
2022-05-03 12:08:10 +02:00
|
|
|
return '/media/thumb/' + this.media.url
|
2022-04-26 23:47:10 +02:00
|
|
|
}
|
|
|
|
if (this.thumb) {
|
|
|
|
return '/noimg.svg'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
thumbnailPosition () {
|
2022-04-27 11:27:08 +02:00
|
|
|
if (this.media.focalpoint) {
|
2022-04-26 23:47:10 +02:00
|
|
|
const focalpoint = this.media.focalpoint
|
|
|
|
return `${(focalpoint[0] + 1) * 50}% ${(focalpoint[1] + 1) * 50}%`
|
|
|
|
}
|
|
|
|
return 'center center'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.img {
|
|
|
|
width: 100%;
|
|
|
|
height: auto;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
2022-04-27 11:27:08 +02:00
|
|
|
display: flex;
|
2022-05-06 23:26:09 +02:00
|
|
|
background-size: contain;
|
2022-04-26 23:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.img img {
|
2022-05-06 23:26:09 +02:00
|
|
|
object-fit: contain;
|
|
|
|
max-height: 125vh;
|
2022-05-03 12:08:10 +02:00
|
|
|
display: flex;
|
2022-04-26 23:47:10 +02:00
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
height: auto;
|
|
|
|
overflow: hidden;
|
2022-05-03 12:08:10 +02:00
|
|
|
transition: opacity .5s;
|
2022-04-26 23:47:10 +02:00
|
|
|
opacity: 1;
|
|
|
|
background-size: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.img.thumb img {
|
|
|
|
display: flex;
|
|
|
|
max-height: 250px;
|
|
|
|
min-height: 160px;
|
|
|
|
object-fit: cover;
|
|
|
|
object-position: top;
|
|
|
|
aspect-ratio: 1.7778;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|