gatsby-plugin-sanity-image icon indicating copy to clipboard operation
gatsby-plugin-sanity-image copied to clipboard

Would it be possible to pass multiple image sources?

Open lanelps opened this issue 2 years ago • 1 comments

I was wondering if it was possible to pass through multiple image sources so that, for example, we're able to use different images at different media sizes? And the output would be 0 or more source elements and a default img element, wrapped by a picture element

lanelps avatar Apr 26 '23 00:04 lanelps

You can do this today:

<picture>
  <SanityImage as="source" {…otherProps} />
  <SanityImage {...otherProps />
</picture>

This does result in a few extraneous attributes on the source tags (e.g. alt) but they are ignored by the browser and don't interfere. I think this is a leaner approach for the library to take for now.

coreyward avatar Apr 28 '23 15:04 coreyward