feat(827): Added fallback on image if is error

This commit is contained in:
Pontus Dreij
2024-11-14 10:02:36 +01:00
parent f3037a1b3d
commit 38c48006be
2 changed files with 8 additions and 5 deletions

View File

@@ -20,9 +20,10 @@ export default function ImageGallery({
}: ImageGalleryProps) {
const intl = useIntl()
const [lightboxIsOpen, setLightboxIsOpen] = useState(false)
const [imageError, setImageError] = useState(false)
const imageProps = fill ? { fill } : { height, width: height * 1.5 }
if (!images || images.length === 0) {
if (!images || images.length === 0 || imageError) {
return <div className={styles.imagePlaceholder} />
}
@@ -38,6 +39,7 @@ export default function ImageGallery({
className={styles.image}
src={images[0].imageSizes.medium}
alt={images[0].metaData.altText}
onError={() => setImageError(true)}
{...imageProps}
/>
<div className={styles.imageCount}>