Skip to content

Commit

Permalink
fix: exclude medium-zoom for img tags directly under a tag (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochefort authored Aug 24, 2021
1 parent 72e1a9d commit 951b0ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion layouts/partials/third-party/medium-zoom.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script src="https://cdn.jsdelivr.net/npm/medium-zoom@latest/dist/medium-zoom.min.js"></script>

<script>
mediumZoom(document.querySelectorAll('div.post-body img'), {
let imgNodes = document.querySelectorAll('div.post-body img');
imgNodes = Array.from(imgNodes).filter(node => node.parentNode.tagName !== "A");

mediumZoom(imgNodes, {
background: 'hsla(var(--color-bg-h), var(--color-bg-s), var(--color-bg-l), 0.95)'
})
</script>

0 comments on commit 951b0ad

Please sign in to comment.