fix: image safe number

This commit is contained in:
DIYgod
2023-04-07 02:48:02 +01:00
parent 92f04875e7
commit a9c44cdf83
+11 -1
View File
@@ -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
<img