sad
This commit is contained in:
@@ -25,6 +25,16 @@ interface ContentImageCellProps {
|
||||
export default function ContentImageCell({ image, maxPromptLength = 100 }: ContentImageCellProps) {
|
||||
const [showFullPrompt, setShowFullPrompt] = useState(false);
|
||||
|
||||
// Check if image_path is a valid local file path (not a URL)
|
||||
const isValidLocalPath = (imagePath: string): boolean => {
|
||||
// Reject URLs (http:// or https://)
|
||||
if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
|
||||
return false;
|
||||
}
|
||||
// Must contain 'ai-images' to be a valid local path
|
||||
return imagePath.includes('ai-images');
|
||||
};
|
||||
|
||||
// Convert local file path to web-accessible URL
|
||||
const getLocalImageUrl = (imagePath: string): string => {
|
||||
// If path contains 'ai-images', convert to web URL
|
||||
@@ -97,15 +107,15 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
|
||||
{image.status === 'generated' && (
|
||||
<div className="space-y-1">
|
||||
{/* Always load from image_path - no fallback */}
|
||||
{image.image_path && image.image_path.trim() ? (
|
||||
{/* Only use image_path if it's a valid local file path (not a URL) */}
|
||||
{image.image_path && image.image_path.trim() && isValidLocalPath(image.image_path) ? (
|
||||
<>
|
||||
<img
|
||||
src={getLocalImageUrl(image.image_path)}
|
||||
alt={prompt || 'Generated image'}
|
||||
className="w-full h-24 object-cover rounded border border-gray-300 dark:border-gray-600"
|
||||
onError={(e) => {
|
||||
// Show error placeholder if local image fails (no fallback to image_url)
|
||||
// Show empty placeholder if local image fails to load
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.style.display = 'none';
|
||||
const parent = target.parentElement;
|
||||
@@ -131,8 +141,8 @@ export default function ContentImageCell({ image, maxPromptLength = 100 }: Conte
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<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 image available</p>
|
||||
<div className="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 className="text-xs text-gray-500 dark:text-gray-400">No image available</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user