-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image caption didn't show #5
Comments
I was able to solve this. Will leave the solution here for anyone interested: The image is rendered through react-markdown, so to add a caption to the image, you will need to add a custom renderer for images. You will find some info here Basicallty, add an image renderer like this in function imgBlock({src, title, alt}) {
return (
<figure>
<img alt={alt} src={src} />
<figcaption class="img-caption">{alt}</figcaption>
</figure>
);
} Then for the renderers: const renderers = {
code: codeBlock,
heading: headingRenderer,
root: RootRenderer,
image: imgBlock,
} |
Hey! Oh, you closed as I was answering, I will add that as an option if the user has an image today :) I'm sorry you had to look in the deep ends of react markdown like I had several times ahah |
Ah sorry! I was still tweaking the code after I posted the issue haha.
That would be great! Thanks a lot for sharing this :) |
Done in this commit: fc47848 Thank you for the good request :) |
Hello!
Thank you Sara for this wonderful template!
I just tried to add a caption to an image today, but I can't seem to have it visible on the development site. I tried adding
showCaptions
to the gatsby-remark-images option:The code for the image looks like this:
But I still can't render the caption:
Can anyone help me find out what's wrong? is this a problem with the gatsby-remark-image itself?
Thanks again!
The text was updated successfully, but these errors were encountered: