fix: show a placeholder when an image cannot be loaded (#27730)
A message referencing a file that no longer exists rendered a broken image, because nothing anywhere noticed the failed load. What the user saw depended on the caller's alt text: in a response the alt is the message content, so the entire reply was rendered inside the image frame, and the preview still opened full-screen on a dead image. Image.svelte now tracks a failed load and renders an 'Image unavailable' placeholder instead, suppressing the preview for a source that cannot be shown. The failed state resets when the source changes, so a replaced or corrected URL is retried. An onError callback lets a caller react without changing behaviour for the eight existing call sites, which are untouched. Responses now pass the file name (or 'Generated Image') as alt rather than the message content, which was never a description of the image.
This commit is contained in:
@@ -690,7 +690,7 @@
|
||||
{#each message.files.filter((f) => ['image', 'file'].includes(f.type)) as file}
|
||||
<div>
|
||||
{#if file.type === 'image' || (file?.content_type ?? '').startsWith('image/')}
|
||||
<Image src={file.url} alt={message.content} />
|
||||
<Image src={file.url} alt={file.name || $i18n.t('Generated Image')} />
|
||||
{:else}
|
||||
<FileItem
|
||||
item={file}
|
||||
|
||||
Reference in New Issue
Block a user