-
I have come across an issue migrating to the new gatsby-plugin-image. I have a page where all articles are listed an you can then click/unclick the different article labels to sort the articles on the page. This is done internally by comparing by comparing the "frontmatter-field" "tags" to all active tags (each article can have up to 3 tags).
With the new plugin I need some way to get the image into my article component (it's deeply nested so traversing up to page level and down again would be a pain). I mistakenly thought I could simply do something along the lines of:
But the {ImageName} prop won't be available at build time, so this really will not work! I have used quite a bit of time trying to figure out how to do this with the dynamic GatsbyImage component but I simply can see how this should be done really - without getting really complicated really fast? Can I somehow "attach" the gatsbyImageData object to every article using gatsby-node.js at buildtime? I have a frontmatter-field on every article with the filename of the image and all images are located in the same folder. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
This is a general problem that I now how encountered several times. I get the following warnings in the chrome console:
and
I see very little explanation in the documentation about how to handle this? It seems like a lot of overhead and code to handle images really? Not sure how this is an improvement over the previous plugin? |
Beta Was this translation helpful? Give feedback.
-
The new image plugin is the same as the old plugin in that regard. If you used this in the past: <Img fluid={cover_image} alt={cover_image_alt} /> Then you'll now use this: <GatsbyImage image={cover_image} alt={cover_image_alt} /> Your https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide |
Beta Was this translation helpful? Give feedback.
The new image plugin is the same as the old plugin in that regard. If you used this in the past:
Then you'll now use this:
Your
cover_image
needs to be in the new shape of course, so notchildImageSharp.fluid
butchildImageSharp.gatsbyImageData
https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide