From a9c44cdf8301db353f6a20bf483b4750d063f3a9 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 7 Apr 2023 02:48:02 +0100 Subject: [PATCH] fix: image safe number --- src/components/ui/Image.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/ui/Image.tsx b/src/components/ui/Image.tsx index 10ad062f..ee24bb6f 100644 --- a/src/components/ui/Image.tsx +++ b/src/components/ui/Image.tsx @@ -16,7 +16,6 @@ export const Image: React.FC< src = toIPFS(src) const [paddingTop, setPaddingTop] = React.useState("0") const [autoWidth, setAutoWidth] = React.useState(0) - const autoSize = !width && !height && !fill const noOptimization = className?.includes("no-optimization") if (!src.startsWith("/assets/")) { @@ -27,6 +26,17 @@ export const Image: React.FC< } } + if (!noOptimization) { + if (width) { + width = +width + } + if (height) { + height = +height + } + } + + const autoSize = !width && !height && !fill + return noOptimization ? ( // eslint-disable-next-line @next/next/no-img-element