Request: keep order of srcsetUrls
phlppschrr opened this issue · comments
phlppschrr commented
It would be nice if there would be a way get the $img->srcsetUrls
array in the same order as defined in the $img->srcset('900,*2,/2')
call.
Another suggestion would be to use 'smallest' and 'largest' instead of 'first'/'last'.
I forked your repo and implemented my suggestions here:
phlppschrr@71d30bc
Background to this request is, I want to use lazysizes like described here:
https://github.com/aFarkas/lazysizes#modern-transparent-srcset-pattern where it is recommended that the first image candidate in data-srcset matches the src fallback image.
With these changes I could do it like this:
<img
data-srcset="<?= $img->srcset('900x0,*2,/2') ?>"
src="<?= $img->srcsetUrls[0] ?>"
srcset="<?= $config->srcsetFallbackDataUri ?>"
alt="<?= $img->description ?>"
data-sizes="auto"
class="lazyload" />
Roland Toth Pal commented
v0.1.2 now works like this, thanks!