Showing cover or first photo as movie trailer poster.

This commit is contained in:
DebaucheryLibrarian 2021-01-25 23:15:41 +01:00
parent 5547ff7e76
commit dba99a4170
1 changed files with 19 additions and 2 deletions

View File

@ -11,7 +11,7 @@
<video <video
v-if="release.trailer" v-if="release.trailer"
:src="`/media/${release.trailer.path}`" :src="`/media/${release.trailer.path}`"
:poster="release.poster && (sfw ? `/img/${release.poster.sfw.thumbnail}` : `/media/${release.poster.thumbnail}`)" :poster="poster"
:alt="release.title" :alt="release.title"
:class="{ sfw: sfw && paused }" :class="{ sfw: sfw && paused }"
class="item trailer" class="item trailer"
@ -23,7 +23,7 @@
<video <video
v-else-if="release.teaser && /^video\//.test(release.teaser.mime)" v-else-if="release.teaser && /^video\//.test(release.teaser.mime)"
:src="`/media/${release.teaser.path}`" :src="`/media/${release.teaser.path}`"
:poster="release.poster && (sfw ? `/img/${release.poster.sfw.thumbnail}` : `/media/${release.poster.thumbnail}`)" :poster="poster"
:alt="release.title" :alt="release.title"
:class="{ sfw: sfw && paused }" :class="{ sfw: sfw && paused }"
class="item trailer" class="item trailer"
@ -114,6 +114,22 @@ function sfw() {
return this.$store.state.ui.sfw; return this.$store.state.ui.sfw;
} }
function poster() {
if (this.release.poster) {
return sfw ? `/img/${this.release.poster.sfw.thumbnail}` : `/media/${this.release.poster.thumbnail}`;
}
if (this.release.covers?.length > 0) {
return this.sfw ? `/img/${this.release.covers[0].sfw.path}` : `/media/${this.release.covers[0].path}`;
}
if (this.photos?.length > 0) {
return this.sfw ? `/img/${this.photos[0].sfw.thumbnail}` : `/media/${this.photos[0].thumbnail}`;
}
return null;
}
function photos() { function photos() {
const clips = this.release.clips || []; const clips = this.release.clips || [];
const clipPostersById = clips.reduce((acc, clip) => ({ ...acc, [clip.poster.id]: clip.poster }), {}); const clipPostersById = clips.reduce((acc, clip) => ({ ...acc, [clip.poster.id]: clip.poster }), {});
@ -157,6 +173,7 @@ export default {
}, },
computed: { computed: {
photos, photos,
poster,
sfw, sfw,
}, },
}; };