fix: show fallback media when loading error (#615)

This commit is contained in:
Stephen Zhou 2024-09-25 10:15:56 +08:00 committed by GitHub
parent 192d5bc8a6
commit 40dfbde85e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -156,11 +156,12 @@ const MediaImpl: FC<MediaProps> = ({
if (!type || !src) return null
if (hidden && showFallback) {
if (hidden && (showFallback || (!showFallback && mediaLoadState === "error"))) {
return (
<FallbackMedia
mediaContainerClassName={mediaContainerClassName}
className={className}
style={style}
{...props}
/>
)
@ -179,7 +180,7 @@ const MediaImpl: FC<MediaProps> = ({
export const Media: FC<MediaProps> = memo((props) => <MediaImpl {...props} key={props.src} />)
const FallbackMedia: FC<MediaProps> = ({ type, mediaContainerClassName, className, ...props }) => (
<div className={className}>
<div className={className} style={props.style}>
<div
className={cn(
!(props.width || props.height) && "size-full",