gatsby-image: Add the ability to have className on actual img element
See original GitHub issueSummary
I have a requirement to add className
to the actual <img>
element to support microformats.
Currently GatsbyJs only has
ClassName
- on the wrapper onlyplaceholderClassName
- on the placeholder<img>
There is no support for the actual <img>
element.
Basic example
<Img
fluid={data['profilePic'].childImageSharp.fluid}
alt={`Ben Shi`}
className={'avatar'}
imgClassName={'u-photo'}
/>
Motivation
In microformats u-photo
is only valid on (<img src>
) elements.
gatsby-image both fixed and fluid does not support this.
http://microformats.org/wiki/microformats-2-implied-properties
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:13 (6 by maintainers)
Top Results From Across the Web
React Gatsbyjs add class to gatsby-image based on aspect ratio
When I map over all my gallery images, I can grab the aspect ratio and add it to each gatsby-image-wrapper using className but...
Read more >Gatsby Image plugin
The Gatsby Image plugin includes two components to display responsive images on your site ... The StaticImage component can take all image options...
Read more >3 Ways to display images in Gatsby JS - YouTube
Plus I'll give you a hot tip on how to utilize bootstrap with Gatsby Img. If you want to jump around: 3:57 |...
Read more >In Depth gatsby-image Tutorial - YouTube
In this video from my Gatsby Basics course I walk through how to use the Gatsby Image component in a number of different...
Read more >Create a Lazy-Loading Image Component with React Hooks
A "load" event listener is added to the source img element so when it finishes loading, the state is updated and a "loaded"...
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 FreeTop 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
Top GitHub Comments
We would like to be able to pass down the css generated by emotion to the img element and it is currently not possible with the current gatsby image component. Any update - to me it looks like the change suggested in #24161 would solve this?
Just thought I’d add that I need this functionality as well, or the ability to pass data attributes to the tag. I’m trying to add an attribute to prevent pinning to Pinterest with certain images and I can’t get the attribute on the actual img tag. If I could at least get a class name on there, then I could add the attribute with Javascript.