mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 12:03:49 +01:00
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
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue