Rich text images with fluid gatsby-image
See original GitHub issueI’m having trouble figuring out how to get images from a Contentful rich text field working with fluid Gatsby images.
Specifically, what does the GraphQL query need to look like? Do I need to edit my gatsby-node.js
allContentfulArticle
query or do I need to add a query to my article-template.js
file?
Also, do I need to use documentToHtmlString
? If so, what element do I need to write a custom renderer for? Will it look similar to the Advanced Example found here?
Thanks for any and all help! Let me know what additional information is needed.
Issue Analytics
- State:
- Created 5 years ago
- Comments:35 (2 by maintainers)
Top Results From Across the Web
No embedded images with rich text but would like to use ...
I'm building a Gatsby site and am using the gatsby-source-contentful plugin as well as the @contentful/rich-text-react-renderer package to ...
Read more >Gatsby Source Contentful 4.x - Rich Text - Stack Overflow
I have a gatsby app for which I am using contentful rich text. contentful recently made some breaking changes to the way content...
Read more >Images and Media - Gatsby
Pull images, video, GIF, and other media into your site. ... Gatsby offers tools to create rich experiences with gatsby-image, while preventing performance ......
Read more >Rendering Gatsby Images from Contentful Rich Text
Gatsby is great at rendering images. To do this, you need to leverage the Gatsby Image Plugin. For most of the images on...
Read more >Image as a Link with Contentful and Gatsby JS
As rich as the Rich Text functionality of Contentful might be, ... Rich Text elements in Gatsby ;) I chose to use a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I got this to work using @AnalogMemory’s concept. Here’s the code example:
And the hook that connects the nodeId to the fluid image.
Then in your blog post or wherever pass the rich text Json into the RichTextRenderer component
<RichTextRenderer richTextJson={bodyTest.json} />
we were able to solve this recently. using @AnalogMemory 's solution didn’t work for us because it was causing a huge json blob to be included in our bundle. this removes the manual process of creating the urls and doesn’t require including all of the contentful assets