react-image-lightbox icon indicating copy to clipboard operation
react-image-lightbox copied to clipboard

Use srcset and sizes attributes?

Open ooloth opened this issue 6 years ago • 5 comments

Is it possible to use responsive image markup (srcset and sizes) with react-image-lightbox?

I'd like to avoid hard-coding a single mainSrc image file to be used on every screen size... Is there a way to dynamically select the mainSrc image based on the viewport width?

ooloth avatar Nov 06 '17 20:11 ooloth

Sadly, I didn't find this valuable feature either.

Max-Zviagintsev avatar Jan 23 '19 09:01 Max-Zviagintsev

I need that feature, too - do be able to display normal / retina images. This markup would be better:

<img src="default.jpg" srcset="default.jpg 1x, default-retina.jpg 2x">

mhp-borisbojic avatar Apr 18 '19 09:04 mhp-borisbojic

This would be a key, useful feature.

chaddjohnson avatar Mar 03 '20 18:03 chaddjohnson

Yep definitely -- same with me

JackHowa avatar May 11 '20 18:05 JackHowa

Looking into this. It looks like there's some styles transform the image dynamically.

with transform css in image Screen Shot 2020-05-13 at 8 20 48 PM

without css transform. at least showing the image at actual size Screen Shot 2020-05-13 at 8 20 57 PM

Basic image passing in being mocked. Let me know if you have any goals for how you'd want to pass in the srcSet, currently thinking:

  // [ { intrinsicSize: '100w', imageUrl: 'https://image.jpg }]
  mainSrcSet: PropTypes.array,

https://github.com/JackHowa/react-image-lightbox/tree/ISSUE-87-image-src-set

JackHowa avatar May 14 '20 01:05 JackHowa