"use client"; import { useState } from "react"; interface SafeImageProps { src: string; alt: string; width?: number; height?: number; style?: React.CSSProperties; fallbackLabel?: string; // initials or short label shown when image fails containerStyle?: React.CSSProperties; } export default function SafeImage({ src, alt, width, height, style, fallbackLabel, containerStyle, }: SafeImageProps) { const [errored, setErrored] = useState(false); if (errored) { if (!fallbackLabel) return null; return (
{fallbackLabel}
); } return ( // eslint-disable-next-line @next/next/no-img-element {alt} setErrored(true)} /> ); }