fix: artwork fallbacks everywhere and hero layout

- resolveItemImage(): try the item's own images, then series/album/parent artwork
- hero sidebar tickers fall back from Thumb to Backdrop/Primary instead of an icon
- hero background falls back to the poster when no backdrop exists
- stop stacked slides when the carousel advances (drop leaking AnimatePresence)
- keep the hero title/logo inside the slide on narrow windows
- sensible slides-per-view on tablet/mobile widths
This commit is contained in:
1xDed committed 2026-11-27 03:11:17 +03:00
1 parent 1c499f42ec
commit 5a9b3ad273
7 files changed
+197 -34

No files matched your search

+10 -5
View File
@@ -10,6 +10,7 @@ import React, { memo, type Ref, useCallback, useState } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { useInView } from "react-intersection-observer";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { resolveItemImage } from "@/utils/methods/itemImages";
import { useApiInContext } from "@/utils/store/api";
import LikeButton from "../buttons/likeButton";
import MarkPlayedButton from "../buttons/markPlayedButton";
@@ -56,6 +57,10 @@ const CardContent = ({
const api = useApiInContext((s) => s.api);
const navigate = useNavigate();
const image = resolveItemImage(item, imageType, {
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
});
const defaultOnClick = useCallback(() => {
if (item?.Id) {
navigate(getItemLinkOptions(item.Id, item?.Type));
@@ -102,20 +107,20 @@ const CardContent = ({
? getTypeIcon(overrideIcon)
: getTypeIcon(item.Type ?? "universal")}
</div>
{inView && (
{inView && image && (
<img
alt={item.Name ?? "blink"}
src={
api
api && image
? overrideIcon === "User"
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
: getImageUrlsApi(api).getItemImageUrlById(
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
"",
imageType,
image.itemId,
image.imageType,
{
quality: 90,
fillWidth: cardType === "thumb" ? 560 : 320,
tag: image.tag,
},
)
: ""
+4 -4
View File
@@ -99,14 +99,14 @@ export default function CardScroller({
},
tablet: {
breakpoint: { max: 925, min: 600 },
items: displayCards - 3,
slidesToSlide: displayCards - 3,
items: Math.max(2, displayCards - 2),
slidesToSlide: Math.max(2, displayCards - 2),
partialVisibilityGutter: 20,
},
mobile: {
breakpoint: { max: 600, min: 424 },
items: displayCards - 5,
slidesToSlide: displayCards - 5,
items: Math.max(1, displayCards - 4),
slidesToSlide: Math.max(1, displayCards - 4),
partialVisibilityGutter: 10,
},
smallScreen: {
+9
View File
@@ -8,6 +8,15 @@
grid-template-columns: 1fr 340px;
gap: 1.5em;
&-slide-wrapper {
grid-area: main;
position: relative;
height: 100%;
min-width: 0;
overflow: hidden;
border-radius: 20px;
}
&-sidebar {
overflow-y: auto;
height: 100%;
+31 -19
View File
@@ -1,5 +1,6 @@
import { AnimatePresence } from "motion/react";
import { motion } from "motion/react";
import React, { useCallback, useEffect, useState } from "react";
import type { Api } from "@jellyfin/sdk";
import { useCarouselStore } from "../../utils/store/carousel";
import "./carousel.scss";
@@ -8,6 +9,7 @@ import {
BaseItemKind,
} from "@jellyfin/sdk/lib/generated-client";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { resolveItemImage } from "@/utils/methods/itemImages";
import { useApiInContext } from "@/utils/store/api";
import CarouselSlide from "../carouselSlide";
import CarouselTickers from "./tickers";
@@ -15,6 +17,24 @@ import CarouselTickers from "./tickers";
// Memoize CarouselSlide to prevent unnecessary re-renders
const MemoizedCarouselSlide = React.memo(CarouselSlide);
/** Sidebar thumbnail: prefer Thumb, fall back to Backdrop/Primary when missing. */
const tickerImageUrl = (
api: Api,
item: BaseItemDto,
): string | undefined => {
const image = resolveItemImage(item, "Thumb");
if (!image) return undefined;
return getImageUrlsApi(api).getItemImageUrlById(
image.itemId,
image.imageType,
{
quality: 90,
fillHeight: 360,
tag: image.tag,
},
);
};
const Carousel = ({
content,
onChange,
@@ -96,12 +116,15 @@ const Carousel = ({
onMouseEnter={() => setIsPaused(true)}
onMouseLeave={() => setIsPaused(false)}
>
<AnimatePresence mode="sync">
<MemoizedCarouselSlide
item={content[currentSlide]}
key={content[currentSlide].Id}
/>
</AnimatePresence>
<motion.div
key={content[currentSlide].Id}
className="hero-carousel-slide-wrapper"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.35, ease: "easeInOut" }}
>
<MemoizedCarouselSlide item={content[currentSlide]} />
</motion.div>
<div className="carousel-sidebar" ref={sidebarRef}>
{content.map((item, index) => (
<div
@@ -112,18 +135,7 @@ const Carousel = ({
className="carousel-ticker-wrapper"
>
<CarouselTickers
imageUrl={
item.ImageTags?.Thumb
? getImageUrlsApi(api).getItemImageUrlById(
item.Id ?? "",
"Thumb",
{
quality: 90,
fillHeight: 360,
},
)
: undefined
}
imageUrl={tickerImageUrl(api, item)}
isActive={index === currentSlide}
itemName={item.Name ?? "Unknown"}
itemYear={
+12 -6
View File
@@ -61,6 +61,16 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
const [animationDirection] = useCarouselStore((state) => [state.direction]);
// Hero background: a real backdrop when the item has one, otherwise fall back
// to the poster instead of a big type icon.
const heroBackgroundSrc = item.BackdropImageTags?.length
? item.ParentBackdropItemId
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
: item.ImageTags?.Primary
? `${api?.basePath}/Items/${item.Id}/Images/Primary?quality=80&fillHeight=1400`
: undefined;
return (
<div className="hero-carousel-slide">
<motion.div
@@ -70,15 +80,11 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
exit={{ opacity: 0 }}
transition={{ duration: 0.4, ease: "easeInOut" }}
>
{item.BackdropImageTags?.length ? (
{heroBackgroundSrc ? (
<img
alt={item.Name ?? "item"}
className="hero-carousel-background-image"
src={
item.ParentBackdropItemId
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
}
src={heroBackgroundSrc}
style={{
opacity: 0,
}}