Skip to content

Commit

Permalink
fix: image previewer was corrupted by size unit (#114)
Browse files Browse the repository at this point in the history
When we set img attribute with unit (e.g. width="100px"), it will be
corrupted.
  • Loading branch information
jeffreytse committed Jun 28, 2023
1 parent 3c6242f commit 5799ef6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions _includes/extensions/photo-swipe.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
imgEl.outerHTML = `
<a class="photo-swipe"
href="${imgEl.src}"
data-width="${imgEl.getAttribute("width") || imgEl.width * 2}"
data-height="${imgEl.getAttribute("height") || imgEl.height * 2}"
data-width="${Math.max(imgEl.naturalWidth, imgEl.width) * 2}"
data-height="${Math.max(imgEl.naturalHeight, imgEl.height) * 2}"
data-caption="${imgEl.getAttribute("caption") || imgEl.alt}"
target="_blank">
${imgEl.outerHTML}
Expand Down Expand Up @@ -63,7 +63,6 @@
bgOpacity: 0.85,
showHideOpacity: true,
closeOnScroll: true,
maxSpreadZoom: 1,
getDoubleTapZoom: (isMouseClick, item) => {
if (item.detail) {
zoomLevel += item.detail.origEvent.shiftKey ? -1 : 1;
Expand Down

0 comments on commit 5799ef6

Please sign in to comment.