We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8bdcc01 commit ec2ededCopy full SHA for ec2eded
src/components/Image.tsx
@@ -33,10 +33,16 @@ const imageProps: (keyof NextImageProps)[] = [
33
"useMap",
34
]
35
36
+const isStaticImageData = (src: ImageProps["src"]): src is StaticImageData => {
37
+ return typeof src === "object" && "blurDataURL" in src
38
+}
39
+
40
const DefaultNextImage = (props: ImageProps) => {
- const hasBlurData = !!(
- (props.src as StaticImageData).blurDataURL || props.blurDataURL
- )
41
+ if (isStaticImageData(props.src)) {
42
+ return <NextImage placeholder="blur" {...props} />
43
+ }
44
45
+ const hasBlurData = !!props.blurDataURL
46
return <NextImage placeholder={hasBlurData ? "blur" : "empty"} {...props} />
47
}
48
0 commit comments