diff --git a/src/components/ui/Image.tsx b/src/components/ui/Image.tsx index 7fe17649..e7204dfa 100644 --- a/src/components/ui/Image.tsx +++ b/src/components/ui/Image.tsx @@ -18,8 +18,27 @@ export const Image: React.FC< const [paddingTop, setPaddingTop] = React.useState("0") const [autoWidth, setAutoWidth] = React.useState(0) const autoSize = !width && !height && !fill + const noOptimization = className?.includes("no-optimization") - return ( + return noOptimization ? ( + // eslint-disable-next-line @next/next/no-img-element + {alt} { + if (autoSize) { + const { naturalWidth, naturalHeight } = target as HTMLImageElement + setPaddingTop(`calc(100% / (${naturalWidth} / ${naturalHeight})`) + setAutoWidth(naturalWidth) + } + }} + ref={imageRef} + /> + ) : (