19 lines
424 B
TypeScript
19 lines
424 B
TypeScript
import Image from "next/image";
|
|
import type { ComponentProps } from "react";
|
|
|
|
const fallbackImage = "/fallback-image.png";
|
|
export const ImageFlbk = (props: ComponentProps<typeof Image>) => {
|
|
return (
|
|
<Image
|
|
{...props}
|
|
onError={(e) => {
|
|
e.currentTarget.src = fallbackImage;
|
|
}}
|
|
onLoad={(e) => {
|
|
if (e.currentTarget.naturalWidth === 0) {
|
|
e.currentTarget.src = fallbackImage;
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
};
|