forked from Sync/hugo-theme-stack
fix: PhotoSwipe not getting the real image dimensions
This is because `img.width.toString()` returns the `<img>` element dimension, not the real image dimension (stored in the `width` attribute). closes https://github.com/CaiJimmy/hugo-theme-stack/issues/934
This commit is contained in:
parent
47a57a2ad2
commit
4d6b65f63c
@ -61,8 +61,8 @@ export default (container: HTMLElement) => {
|
||||
const a = document.createElement('a');
|
||||
a.href = img.src;
|
||||
a.setAttribute('target', '_blank');
|
||||
a.setAttribute('data-pswp-width', img.width.toString());
|
||||
a.setAttribute('data-pswp-height', img.height.toString());
|
||||
a.setAttribute('data-pswp-width', img.getAttribute('width'));
|
||||
a.setAttribute('data-pswp-height', img.getAttribute('height'));
|
||||
img.parentNode.insertBefore(a, img);
|
||||
a.appendChild(img);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user