From e8944528e4d9b93324913221e5e71f91066873c2 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 25 Aug 2024 20:56:52 +0200 Subject: [PATCH] fix: failover for posters --- components/ContinueWatchingPoster.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/components/ContinueWatchingPoster.tsx b/components/ContinueWatchingPoster.tsx index a28bc706..31b3f5ea 100644 --- a/components/ContinueWatchingPoster.tsx +++ b/components/ContinueWatchingPoster.tsx @@ -17,12 +17,23 @@ const ContinueWatchingPoster: React.FC = ({ }) => { const [api] = useAtom(apiAtom); + /** + * Get horrizontal poster for movie and episode, with failover to primary. + */ const url = useMemo(() => { if (!api) return; - if (item.Type === "Episode") - return `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ParentThumbImageTag}`; - if (item.Type === "Movie") - return `${api?.basePath}/Items/${item.Id}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ImageTags?.["Thumb"]}`; + if (item.Type === "Episode") { + if (item.ParentBackdropItemId && item.ParentThumbImageTag) + return `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ParentThumbImageTag}`; + else + return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`; + } + if (item.Type === "Movie") { + if (item.ImageTags?.["Thumb"]) + return `${api?.basePath}/Items/${item.Id}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ImageTags?.["Thumb"]}`; + else + return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`; + } }, [item]); const [progress, setProgress] = useState(