Skip to content

Commit e11c970

Browse files
TylerBarnesgatsbybot
and
gatsbybot
authored
fix(gatsby-plugin-sharp): error if we can't determine dimensio… (#23156)
* error if we can't determine dimensions for image * chore: format Co-authored-by: gatsbybot <[email protected]>
1 parent 05eb934 commit e11c970

File tree

1 file changed

+8
-0
lines changed
  • packages/gatsby-plugin-sharp/src

1 file changed

+8
-0
lines changed

packages/gatsby-plugin-sharp/src/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ const getImageSize = file => {
3030
const dimensions = imageSize.sync(
3131
toArray(fs.readFileSync(file.absolutePath))
3232
)
33+
34+
if (!dimensions) {
35+
reportError(
36+
`gatsby-plugin-sharp couldn't determine dimensions for file:\n${file.absolutePath}\nThis file is unusable and is most likely corrupt.`,
37+
``
38+
)
39+
}
40+
3341
imageSizeCache.set(file.internal.contentDigest, dimensions)
3442
return dimensions
3543
}

0 commit comments

Comments
 (0)