diff --git a/components/home/lovart/lovart-featured-gallery.tsx b/components/home/lovart/lovart-featured-gallery.tsx index 05a147964..16e7a8c0c 100644 --- a/components/home/lovart/lovart-featured-gallery.tsx +++ b/components/home/lovart/lovart-featured-gallery.tsx @@ -13,6 +13,16 @@ type LovartFeaturedGalleryProps = { setActiveCategory: (category: string) => void; }; +function getFeaturedPreviewUrl(item: FeaturedImage) { + const source = item.thumbnailUrl || item.originalUrl; + + if (!source || !/^https:\/\/yybb\.top\//i.test(source) || source.includes("?")) { + return source; + } + + return `${source}?imageView2/2/w/900/q/78`; +} + export function LovartFeaturedGallery({ activeCategory, categories, @@ -60,10 +70,21 @@ export function LovartFeaturedGallery({ className="group mb-[24px] block w-full cursor-pointer break-inside-avoid text-left" > {item.prompt { + const image = event.currentTarget; + const fallbackUrl = item.originalUrl || item.thumbnailUrl; + + if (!fallbackUrl || image.dataset.fallbackApplied === "true") { + return; + } + + image.dataset.fallbackApplied = "true"; + image.src = fallbackUrl; + }} className="block h-auto w-full rounded-[6px] bg-[#e8e8e8] object-cover transition-transform duration-150 ease-out will-change-transform group-hover:scale-[1.008] dark:bg-[#1b1c20]" />