PhotoSwipe
PhotoSwipe copied to clipboard
added natural image height and width without defined it with data-psw…
- Added support for undefined height and width on images with using naturalWidth and naturalHeight of the images. Discussion référence : Photoswipe 5 without defining image width and height? #1988
The data-pswp-width and data-pswp-height still working, but now it is optional.
before
<ul id="my-gallery">
<li>
<a href="https://..." data-pswp-width="1669" data-pswp-height="2500" target="_blank">
<img src="https://..." alt="" loading="lazy">
</a>
</li>
</ul>
after
<ul id="my-gallery">
<li>
<a href="https://..." target="_blank">
<img src="https://..." alt="" loading="lazy">
</a>
</li>
</ul>
I'm not sure that relying on thumbnail dimensions is a good idea, especially as a default behavior. The domItemData
filter allows you to do this without modifying the lib.
I think setting the default width and height is a good idea. Once the width and height preview is not set, there will be problems. Setting the default width and height can be used as a compatibility solution
Yes, this is not a big problem. Both data-pswp-width and data-pswp-height can be dynamically assigned after the image is loaded.