fix: skip rendering img element when src is empty in image preview dialog

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-02 15:26:17 +08:00
parent f23ed12650
commit 9b50d75266

View File

@@ -42,13 +42,15 @@ function ImagePreviewDialog({
> >
<X className="h-5 w-5" /> <X className="h-5 w-5" />
</button> </button>
{/* eslint-disable-next-line @next/next/no-img-element */} {src && (
<img /* eslint-disable-next-line @next/next/no-img-element */
src={src} <img
alt={alt} src={src}
onClick={(e) => e.stopPropagation()} alt={alt}
className="max-h-[90vh] max-w-[90vw] rounded-lg object-contain" onClick={(e) => e.stopPropagation()}
/> className="max-h-[90vh] max-w-[90vw] rounded-lg object-contain"
/>
)}
</DialogPrimitive.Content> </DialogPrimitive.Content>
</DialogPrimitive.Portal> </DialogPrimitive.Portal>
</DialogPrimitive.Root> </DialogPrimitive.Root>