Skip to content

getSrc helper from gatsby-plugin-image return return undefined with resize option from sharp #33087

Answered by LekoArts
lezan asked this question in Help
Discussion options

You must be logged in to vote

The helper functions only work if you use the gatsbyImageData object: https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-plugin-image/#helper-functions

You can see the source code here:

export const getImage = (node: ImageDataLike): IGatsbyImageData | undefined => {
if (isGatsbyImageData(node)) {
return node
}
if (isGatsbyImageDataParent(node)) {
return node.gatsbyImageData
}
return node?.childImageSharp?.gatsbyImageData
}
export const getSrc = (node: ImageDataLike): string | undefined =>
getImage(node)?.images?.fallback?.src

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lezan
Comment options

Answer selected by lezan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants