Skip to content

Commit 85ec41b

Browse files
committed
feat: add item image popout for non-GM players
1 parent 22787ae commit 85ec41b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

scripts/item-image-popout.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Hooks.on('renderItemSheet', (sheet, html, data) => {
2+
if (game.user.isGM) return;
3+
4+
// html is jQuery in v12, HTMLElement in v13
5+
const element = html instanceof jQuery ? html[0] : html;
6+
const img = element.querySelector('img[data-edit="img"]');
7+
if (!img) return;
8+
9+
// Remove data-edit so Foundry's file picker doesn't intercept clicks
10+
img.removeAttribute('data-edit');
11+
img.style.cursor = 'pointer';
12+
13+
img.addEventListener('click', (event) => {
14+
event.preventDefault();
15+
event.stopPropagation();
16+
17+
const src = img.getAttribute('src');
18+
const title = sheet.object.name;
19+
20+
// v13 uses ApplicationV2-style options, v12 uses positional args
21+
if (foundry.applications?.apps?.ImagePopout) {
22+
new foundry.applications.apps.ImagePopout({
23+
src: src,
24+
window: { title: title }
25+
}).render(true);
26+
} else {
27+
new ImagePopout(src, { title: title }).render(true);
28+
}
29+
});
30+
});

0 commit comments

Comments
 (0)