Update ContentImageCell.tsx
This commit is contained in:
@@ -97,7 +97,7 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
|
||||
{image.status === 'generated' && (
|
||||
<div className="space-y-1">
|
||||
{/* Always show image from image_path if available, otherwise from image_url */}
|
||||
{/* Always load from image_path if available */}
|
||||
{image.image_path && image.image_path.trim() ? (
|
||||
<>
|
||||
<img
|
||||
@@ -105,13 +105,12 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
alt={prompt || 'Generated image'}
|
||||
className="w-full h-24 object-cover rounded border border-gray-300 dark:border-gray-600"
|
||||
onError={(e) => {
|
||||
// Fallback to original URL if local image fails
|
||||
// Show error placeholder if local image fails (no fallback to image_url)
|
||||
const target = e.target as HTMLImageElement;
|
||||
if (image.image_url) {
|
||||
target.src = image.image_url;
|
||||
} else {
|
||||
target.style.display = 'none';
|
||||
target.parentElement!.innerHTML = `
|
||||
target.style.display = 'none';
|
||||
const parent = target.parentElement;
|
||||
if (parent) {
|
||||
parent.innerHTML = `
|
||||
<div class="w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">Image not available</p>
|
||||
</div>
|
||||
@@ -119,6 +118,7 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/* Always show "View Original" button if image_url is available */}
|
||||
{image.image_url && (
|
||||
<a
|
||||
href={image.image_url}
|
||||
@@ -131,6 +131,7 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
)}
|
||||
</>
|
||||
) : image.image_url ? (
|
||||
// Fallback: if no image_path, show image_url (for backward compatibility)
|
||||
<a
|
||||
href={image.image_url}
|
||||
target="_blank"
|
||||
@@ -145,17 +146,20 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
// Fallback to placeholder if image fails to load
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.style.display = 'none';
|
||||
target.parentElement!.innerHTML = `
|
||||
<div class="w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">Image not available</p>
|
||||
</div>
|
||||
`;
|
||||
const parent = target.parentElement;
|
||||
if (parent) {
|
||||
parent.innerHTML = `
|
||||
<div class="w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">Image not available</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</a>
|
||||
) : (
|
||||
<div className="w-full h-24 bg-yellow-100 dark:bg-yellow-900/20 rounded border border-yellow-300 dark:border-yellow-700 flex items-center justify-center">
|
||||
<p className="text-xs text-yellow-700 dark:text-yellow-400">No URL available</p>
|
||||
<p className="text-xs text-yellow-700 dark:text-yellow-400">No image available</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user