feat: check image src
This commit is contained in:
parent
0f2abe9e44
commit
7a1fc5d3e8
|
|
@ -1,7 +1,6 @@
|
|||
import React from "react"
|
||||
import { default as NextImage, ImageProps } from "next/image"
|
||||
import { toGateway, toIPFS } from "~/lib/ipfs-parser"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const Image: React.FC<
|
||||
{
|
||||
|
|
@ -20,6 +19,12 @@ export const Image: React.FC<
|
|||
const autoSize = !width && !height && !fill
|
||||
const noOptimization = className?.includes("no-optimization")
|
||||
|
||||
try {
|
||||
new URL(src)
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
|
||||
return noOptimization ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
|
|
|
|||
Loading…
Reference in New Issue