import React, { useState } from 'react' const FALLBACK_MD = 'https://files.skinbase.org/default/missing_md.webp' const FALLBACK_LG = 'https://files.skinbase.org/default/missing_lg.webp' const FALLBACK_XL = 'https://files.skinbase.org/default/missing_xl.webp' export default function ArtworkHero({ artwork, presentMd, presentLg, presentXl }) { const [isLoaded, setIsLoaded] = useState(false) const mdSource = presentMd?.url || artwork?.thumbs?.md?.url || null const lgSource = presentLg?.url || artwork?.thumbs?.lg?.url || null const xlSource = presentXl?.url || artwork?.thumbs?.xl?.url || null const md = mdSource || FALLBACK_MD const lg = lgSource || FALLBACK_LG const xl = xlSource || FALLBACK_XL const hasRealArtworkImage = Boolean(mdSource || lgSource || xlSource) const blurBackdropSrc = mdSource || lgSource || xlSource || null const srcSet = `${md} 640w, ${lg} 1280w, ${xl} 1920w` return (
{blurBackdropSrc && (
)} {hasRealArtworkImage && (
)}
{artwork?.title {artwork?.title setIsLoaded(true)} onError={(event) => { event.currentTarget.src = FALLBACK_LG }} />
{hasRealArtworkImage && (
)}
) }