"use client"; import Image from "next/image"; import { ImageOffIcon } from "lucide-react"; import { useState } from "react"; import { cn } from "@/lib/utils"; interface MediaImageProps { mediaId: string | null | undefined; alt: string; className?: string; fit?: "cover" | "contain"; priority?: boolean; } export function MediaImage({ mediaId, alt, className, fit = "cover", priority = false, }: MediaImageProps) { const [failedId, setFailedId] = useState(null); const failed = !mediaId || failedId === mediaId; return (
{failed ? (
) : ( {alt} setFailedId(mediaId)} /> )}
); }