Skip to content

Commit 9f534aa

Browse files
filzrevp-kostov
authored andcommitted
chore: Fix picture image click event handling (dotnet#9575)
chore: fix picture image handling
1 parent 7b67d3a commit 9f534aa

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

templates/modern/src/markdown.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,18 @@ async function renderClickableImage() {
114114
const a = document.createElement('a')
115115
a.target = '_blank'
116116
a.rel = 'noopener noreferrer nofollow'
117-
a.href = img.src
118-
img.replaceWith(a)
119-
a.appendChild(img)
117+
118+
if (img.parentElement.tagName === 'PICTURE') {
119+
const picture = img.parentElement
120+
picture.addEventListener('click', () => {
121+
a.href = img.currentSrc
122+
a.click()
123+
})
124+
} else {
125+
a.href = img.src
126+
img.replaceWith(a)
127+
a.appendChild(img)
128+
}
120129
}
121130

122131
function shouldMakeClickable(): boolean {

0 commit comments

Comments
 (0)