Skip to content

A self-hosted media server and file management system

fix: image sizes broken with new lazy poster

aminnausinbd6b2cffb25a
diff --git a/resources/js/components/cedar-ui/context-menu/ContextMenu.vue b/resources/js/components/cedar-ui/context-menu/ContextMenu.vue
index 11c7f676..dc9da97d 100644
--- a/resources/js/components/cedar-ui/context-menu/ContextMenu.vue
+++ b/resources/js/components/cedar-ui/context-menu/ContextMenu.vue
@@ -122,7 +122,10 @@ defineExpose({ contextMenuToggle, contextMenuOpen });
}
"
ref="contextMenu"
- :class="['bg-overlay-2-t border-overlay-border/10 absolute z-50 w-48 max-w-[100vw] rounded-md border p-1 shadow-xs backdrop-blur-xs transition-all', style]"
+ :class="[
+ 'bg-overlay-2-t border-overlay-border/10 pointer-events-auto absolute z-50 w-48 max-w-[100vw] rounded-md border p-1 shadow-xs backdrop-blur-xs transition-all',
+ style,
+ ]"
:style="menuStyles"
v-cloak
>
diff --git a/resources/js/components/lazy/LazyImage.vue b/resources/js/components/lazy/LazyImage.vue
index 7e74c901..f0a7a4ff 100644
--- a/resources/js/components/lazy/LazyImage.vue
+++ b/resources/js/components/lazy/LazyImage.vue
@@ -22,13 +22,12 @@ watch(
);
</script>
<template>
- <div :class="cn('relative inline-block h-full w-full', wrapperClass)">
+ <div :class="cn('block h-full w-full', wrapperClass)">
<div v-show="src && isLoading && !isError" class="absolute inset-0 flex items-center justify-center">
<SvgSpinners90RingWithBg class="size-4" />
</div>
<img
v-bind="attrs"
- :key="src"
:loading="loading"
:alt="alt"
:src="src"
diff --git a/resources/js/components/video/PlayerBackdrop.vue b/resources/js/components/video/PlayerBackdrop.vue
index 4b76f9d9..f42d6e64 100644
--- a/resources/js/components/video/PlayerBackdrop.vue
+++ b/resources/js/components/video/PlayerBackdrop.vue
@@ -13,15 +13,17 @@ const props = defineProps<{
isAspectVideo: boolean;
};
isThumbnailDismissed?: boolean;
- audio_poster_url: string;
- poster_url?: string;
+ audioPosterUrl: string;
+ posterUrl?: string;
+ isLoading?: boolean;
+ isVisible?: boolean;
}>();
const isAudio = inject<boolean>('isAudio');
const audioPosterStyle = computed<HTMLAttributes['style']>(() => {
return {
- backgroundImage: `url("${props.audio_poster_url}")`,
+ backgroundImage: `url("${props.audioPosterUrl}")`,
backgroundPosition: 'center',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
@@ -30,25 +32,49 @@ const audioPosterStyle = computed<HTMLAttributes['style']>(() => {
</script>
<template>
+ <!-- <LazyImage :src="audioPosterUrl" alt="Album Art" class="mx-auto h-full max-h-full max-w-full object-contain select-none" loading="eager" fetchpriority="high" /> -->
+ <!-- <img :src="audioPosterUrl" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
<div
+ v-if="isVisible"
:class="[
- 'pointer-events-none absolute top-0 left-0 z-3 flex h-full w-full items-center',
- (isAudio || aspectRatio.isPortrait) && isNormalView ? 'max-h-[71vh]' : 'aspect-video',
+ 'pointer-events-none relative z-3',
+ // (isAudio || aspectRatio.isPortrait) && isNormalView ? 'min-h-[56.25cqw]' : 'aspect-video',
+ // isAudio && !isLoading ? 'min-h-[56.25cqw]' : 'absolute inset-0',
+ // 'absolute inset-0',
+ { 'aspect-video': aspectRatio.isAspectVideo },
]"
>
- <div class="relative isolate h-full w-full">
- <template v-if="isAudio">
- <div id="audio-poster" class="absolute inset-0 z-0 scale-105 blur-sm dark:scale-100" :style="audioPosterStyle"></div>
- <LazyImage :src="audio_poster_url" alt="Album Art" class="mx-auto h-full object-contain select-none" loading="eager" fetchpriority="high" />
- </template>
+ <template v-if="isAudio">
+ <div id="audio-poster" class="absolute inset-0 -z-10 scale-105 blur-sm dark:scale-100" :style="audioPosterStyle"></div>
+ <!-- <img :src="audioPosterUrl" :class="['mx-auto h-screen object-contain select-none', { 'max-h-[71vh]': isNormalView }]" /> -->
<LazyImage
- v-show="!isAudio && poster_url && !isThumbnailDismissed"
- :src="handleStorageURL(poster_url) ?? ''"
- alt="Thumbnail"
- :class="['mx-auto h-full']"
+ :src="audioPosterUrl"
+ alt="Album Art"
+ :class="['mx-auto h-screen object-contain select-none', { 'max-h-[71vh]': isNormalView }]"
loading="eager"
fetchpriority="high"
/>
- </div>
+ <!-- <img :src="audioPosterUrl" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
+ </template>
+ <!-- <img v-show="!isAudio && posterUrl && !isThumbnailDismissed" :src="handleStorageURL(posterUrl) ?? ''" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
+ <!-- <img
+ v-if="!isAudio && posterUrl && !isThumbnailDismissed"
+ :src="handleStorageURL(posterUrl) ?? ''"
+ :class="['z-3 mx-auto h-full object-cover', { 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"
+ /> -->
+ <LazyImage
+ v-show="!isAudio && posterUrl && !isThumbnailDismissed"
+ :src="handleStorageURL(posterUrl) ?? ''"
+ alt="Thumbnail"
+ :wrapper-class="[{ 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"
+ :class="['z-3 mx-auto h-full object-cover']"
+ loading="eager"
+ fetchpriority="high"
+ />
</div>
</template>
+<style lang="css" scoped>
+.poster-container {
+ --width: calc();
+}
+</style>
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 26c93fd9..79398d5a 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -367,7 +367,7 @@ const isAudio = computed(() => {
});
const aspectRatio = computed(() => {
- if (!stateVideo.value.metadata?.resolution_width || !stateVideo.value.metadata?.resolution_height) return { isPortrait: false, isAspectVideo: false };
+ if (isAudio.value || !stateVideo.value.metadata?.resolution_width || !stateVideo.value.metadata?.resolution_height) return { isPortrait: false, isAspectVideo: false };
return {
isPortrait: stateVideo.value.metadata.resolution_width < stateVideo.value.metadata.resolution_height,
@@ -1174,9 +1174,16 @@ defineExpose({
<template>
<div
- :class="cn('relative overflow-clip rounded-lg', { 'theatre-mode': isTheatreView }, { 'rounded-sm': isFullScreen })"
+ :class="
+ cn(
+ 'relative overflow-clip rounded-lg',
+ { 'theatre-mode': isTheatreView },
+ { 'rounded-sm': isFullScreen },
+ { 'max-h-[71vh]': isNormalView && !aspectRatio.isAspectVideo },
+ )
+ "
ref="player-container"
- id="video-container"
+ id="player-container"
@mousemove="playerMouseActivity"
@touchmove="playerMouseActivity"
@mouseleave="handleControlsTimeout"
@@ -1187,60 +1194,63 @@ defineExpose({
}
"
>
- <video
- id="video-source"
- width="100%"
- type="video/mp4"
- ref="player"
- preload="metadata"
- :style="{ 'z-index': 3, '--subtitle-font-multiplier': playerSubtitles?.subtitleSizeMultiplier ?? 1 }"
- :class="
- cn(
- `relative h-full object-contain select-none focus:outline-hidden`,
- stateVideo?.path ? ((isAudio || aspectRatio.isPortrait) && isNormalView ? 'h-[71vh]' : 'aspect-video') : 'aspect-video',
- { 'bg-black': !isAudio && !aspectRatio.isAspectVideo },
- isShowingControls ? 'cursor-auto' : 'cursor-none',
- isFullScreen || isTheatreView
- ? '[--subtitle-cue-size:1.2rem] [--subtitle-font-size:180%]'
- : '[--subtitle-cue-size:0.8em] [--subtitle-font-size:100%] sm:[--subtitle-font-size:136%]',
- '[--subtitle-bottom-offset:0.5em]',
- { '[--subtitle-bottom-offset:3em] sm:[--subtitle-bottom-offset:2em]': isShowingControls },
- )
- "
- :src="stateVideo?.path ? encodeURIComponent(`../${stateVideo.path}`) : ''"
- @play="isPaused = false"
- @pause="isPaused = true"
- @ended="onPlayerEnded"
- @loadstart="onPlayerLoadStart"
- @loadedmetadata="onPlayerLoadeddata"
- @seeked="onSeeked"
- @waiting="onPlayerWaiting"
- @timeupdate="handlePlayerTimeUpdate"
- @click="handlePlayerToggle"
- @enterpictureinpicture="enterPictureInPicture"
- @leavepictureinpicture="leavePictureInPicture"
- aria-describedby="Play/Pause"
- controlsList="nodownload"
- >
- <track
- kind="captions"
- v-if="playerSubtitles?.currentSubtitleTrack?.codec !== 'ass'"
- :label="playerSubtitles?.currentSubtitleTrack?.language ?? 'und'"
- :srclang="playerSubtitles?.currentSubtitleTrack?.language ?? 'und'"
- :src="playerSubtitles?.currentSubtitleTrackUrl"
+ <div :class="['z-3 h-full', { 'max-h-[71vh]': isNormalView && !aspectRatio.isAspectVideo }, { 'bg-black/10': isLoading }]">
+ <video
+ id="video-source"
+ width="100%"
+ type="video/mp4"
+ ref="player"
+ preload="metadata"
+ :style="{ '--subtitle-font-multiplier': playerSubtitles?.subtitleSizeMultiplier ?? 1 }"
+ :class="
+ cn(
+ `absolute h-full object-contain select-none focus:outline-hidden`,
+ { 'static z-3': !isAudio && (!stateVideo.metadata?.poster_url || (stateVideo.metadata.poster_url && isThumbnailDismissed)) }, // Force position if no poster exists
+ { 'aspect-video': !stateVideo.path || aspectRatio.isAspectVideo }, // Default size before load is possible
+ { 'max-h-[71vh]': aspectRatio.isPortrait && isNormalView },
+ { 'bg-black': !isAudio && !aspectRatio.isAspectVideo },
+ isShowingControls ? 'cursor-auto' : 'cursor-none',
+ isFullScreen || isTheatreView
+ ? '[--subtitle-cue-size:1.2rem] [--subtitle-font-size:180%]'
+ : '[--subtitle-cue-size:0.8em] [--subtitle-font-size:100%] sm:[--subtitle-font-size:136%]',
+ '[--subtitle-bottom-offset:0.5em]',
+ { '[--subtitle-bottom-offset:3em] sm:[--subtitle-bottom-offset:2em]': isShowingControls },
+ )
+ "
+ :src="stateVideo?.path ? encodeURIComponent(`../${stateVideo.path}`) : ''"
+ @play="isPaused = false"
+ @pause="isPaused = true"
+ @ended="onPlayerEnded"
+ @loadstart="onPlayerLoadStart"
+ @loadedmetadata="onPlayerLoadeddata"
+ @seeked="onSeeked"
+ @waiting="onPlayerWaiting"
+ @timeupdate="handlePlayerTimeUpdate"
+ @click="handlePlayerToggle"
+ @enterpictureinpicture="enterPictureInPicture"
+ @leavepictureinpicture="leavePictureInPicture"
+ aria-describedby="Play/Pause"
+ controlsList="nodownload"
+ >
+ <track
+ kind="captions"
+ v-if="playerSubtitles?.currentSubtitleTrack?.codec !== 'ass'"
+ :label="playerSubtitles?.currentSubtitleTrack?.language ?? 'und'"
+ :srclang="playerSubtitles?.currentSubtitleTrack?.language ?? 'und'"
+ :src="playerSubtitles?.currentSubtitleTrackUrl"
+ />
+ Your browser does not support the video tag.
+ </video>
+ <!-- The thumbnail or blurred copy of the album art as a backdrop to the clear art (Z-3) -->
+ <PlayerBackdrop
+ :aspect-ratio="aspectRatio"
+ :audio-poster-url="audioPoster"
+ :poster-url="stateVideo.metadata?.poster_url"
+ :is-thumbnail-dismissed="isThumbnailDismissed"
+ :is-normal-view="isNormalView"
+ :is-visible="isAudio || (!!stateVideo.metadata?.poster_url && !isThumbnailDismissed)"
/>
- Your browser does not support the video tag.
- </video>
-
- <!-- The thumbnail or blurred copy of the album art as a backdrop to the clear art (Z-3) -->
- <!-- (Thumbnail only shows when player has never started) (Album art is always visible) -->
- <PlayerBackdrop
- :aspect-ratio="aspectRatio"
- :audio_poster_url="audioPoster"
- :poster_url="stateVideo.metadata?.poster_url"
- :is-thumbnail-dismissed="isThumbnailDismissed"
- :is-normal-view="isNormalView"
- />
+ </div>
<div
style="z-index: 4"
@@ -1689,7 +1699,7 @@ defineExpose({
</Transition>
</div>
- <div class="absolute top-0 left-0 h-full w-full" v-show="isFullScreen || isTheatreView">
+ <div class="pointer-events-none absolute top-0 left-0 h-full w-full" v-show="isFullScreen || isTheatreView">
<ToastController :teleport-disabled="true" :position="'bottom-left'" />
<ContextMenu
ref="contextMenu"