Skip to content

Commit

Permalink
fix(gatsby-plugin-sharp): error if we can't determine dimensio… (#23156)
Browse files Browse the repository at this point in the history
* error if we can't determine dimensions for image

* chore: format

Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
TylerBarnes and gatsbybot authored Apr 16, 2020
1 parent 05eb934 commit e11c970
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/gatsby-plugin-sharp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const getImageSize = file => {
const dimensions = imageSize.sync(
toArray(fs.readFileSync(file.absolutePath))
)

if (!dimensions) {
reportError(
`gatsby-plugin-sharp couldn't determine dimensions for file:\n${file.absolutePath}\nThis file is unusable and is most likely corrupt.`,
``
)
}

imageSizeCache.set(file.internal.contentDigest, dimensions)
return dimensions
}
Expand Down

0 comments on commit e11c970

Please sign in to comment.