Skip to content

Commit 4b0ec0d

Browse files
stenhougaardclaude
andcommitted
Make images clickable when both _src and _link fields exist
Fix bookmarklet rendering to wrap images in anchor tags when both image source and link URL are present. This enables users to click on thumbnails to navigate to the linked content. Changes: - Check for link companion when rendering images (both array and single values) - Wrap <img> in <a> tag with target="_blank" if link exists - Preserve non-clickable image rendering when no link is present - Apply absolute URL conversion to both image sources and links Example usage that now creates clickable images: { "videos_src": "img@src", "videos_link": "a@href" } 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 83576a5 commit 4b0ec0d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/utils/landing.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,18 @@ export function generateLandingPage(baseUrl: string): string {
996996
img.src = toAbsoluteUrl(src);
997997
if (alt) img.alt = alt;
998998
img.style.cssText = 'max-width:100%;height:auto;border-radius:4px;display:block;';
999-
li.appendChild(img);
999+
1000+
// Wrap image in link if link exists
1001+
if (link) {
1002+
const a = document.createElement('a');
1003+
a.href = toAbsoluteUrl(link);
1004+
a.target = '_blank';
1005+
a.style.cssText = 'display:block;';
1006+
a.appendChild(img);
1007+
li.appendChild(a);
1008+
} else {
1009+
li.appendChild(img);
1010+
}
10001011
10011012
if (v) {
10021013
const caption = document.createElement('div');
@@ -1030,7 +1041,18 @@ export function generateLandingPage(baseUrl: string): string {
10301041
img.src = toAbsoluteUrl(srcs);
10311042
if (alts) img.alt = alts;
10321043
img.style.cssText = 'max-width:100%;height:auto;border-radius:4px;display:block;';
1033-
content.appendChild(img);
1044+
1045+
// Wrap image in link if link exists
1046+
if (links) {
1047+
const a = document.createElement('a');
1048+
a.href = toAbsoluteUrl(links);
1049+
a.target = '_blank';
1050+
a.style.cssText = 'display:block;';
1051+
a.appendChild(img);
1052+
content.appendChild(a);
1053+
} else {
1054+
content.appendChild(img);
1055+
}
10341056
10351057
if (value) {
10361058
const caption = document.createElement('div');

0 commit comments

Comments
 (0)