|
| 1 | +# Item Image Popout — Design Spec |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The `coc7-qol` FoundryVTT module adds a click-to-view behavior on item sheet images for non-GM players. Clicking the item portrait opens FoundryVTT's built-in `ImagePopout` window showing the full-size image in a draggable, resizable floating window. |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +In the CoC7 system, item sheet images (`img[data-edit="img"]`) are wired to open a file picker on click — useful for GMs who want to change the image, but useless for players who cannot edit. Players currently have no way to view item art at full size. |
| 10 | + |
| 11 | +## Module Structure |
| 12 | + |
| 13 | +``` |
| 14 | +coc7-qol/ |
| 15 | +├── module.json # Module manifest |
| 16 | +└── scripts/ |
| 17 | + └── item-image-popout.js # Single ES module with hook registration |
| 18 | +``` |
| 19 | + |
| 20 | +## module.json |
| 21 | + |
| 22 | +- **id:** `coc7-qol` |
| 23 | +- **title:** `CoC7 QoL Improvements` |
| 24 | +- **system:** `CoC7` (only activates when the CoC7 system is active) |
| 25 | +- **compatibility:** minimum FoundryVTT v12, verified v13 |
| 26 | +- **esmodules:** `["scripts/item-image-popout.js"]` |
| 27 | + |
| 28 | +## Behavior |
| 29 | + |
| 30 | +### Hook |
| 31 | + |
| 32 | +`renderItemSheet` — fires for every item sheet type in CoC7. |
| 33 | + |
| 34 | +### Target Element |
| 35 | + |
| 36 | +`img[data-edit="img"]` within the rendered sheet HTML. |
| 37 | + |
| 38 | +This selector was chosen over class-based selectors (`.photo`, `.profile`, `.profile-img`) because all CoC7 item sheet templates use the `data-edit="img"` attribute on their portrait image, regardless of which CSS class they use. |
| 39 | + |
| 40 | +### Guard |
| 41 | + |
| 42 | +Only activates when `game.user.isGM` is `false`. |
| 43 | + |
| 44 | +### Non-GM Behavior |
| 45 | + |
| 46 | +1. Find `img[data-edit="img"]` in the rendered sheet HTML element. |
| 47 | +2. Remove the `data-edit="img"` attribute so Foundry's built-in file picker handler does not intercept the click. |
| 48 | +3. Set `cursor: pointer` on the image to indicate it is clickable. |
| 49 | +4. Attach a click handler that calls: |
| 50 | + ```js |
| 51 | + new ImagePopout(img.getAttribute("src"), { title: sheet.object.name }).render(true); |
| 52 | + ``` |
| 53 | + |
| 54 | +### GM Behavior |
| 55 | + |
| 56 | +Unchanged. The GM retains the default file picker behavior provided by FoundryVTT core. |
| 57 | + |
| 58 | +## Scope |
| 59 | + |
| 60 | +### Included (all item sheets) |
| 61 | + |
| 62 | +Weapons, spells, books, skills, armor, talents, occupations, archetypes, statuses, setups, experience packages, chases, and the generic item sheet (item-sheetV2). |
| 63 | + |
| 64 | +### Excluded |
| 65 | + |
| 66 | +Actor sheets (characters, NPCs, creatures, vehicles, containers) are not affected. |
| 67 | + |
| 68 | +## Technical Notes |
| 69 | + |
| 70 | +- `ImagePopout` is a built-in FoundryVTT Application class — no external dependencies needed. |
| 71 | +- The `renderItemSheet` hook provides `(sheet, html, data)` where `html` is a jQuery object (v12) or HTMLElement (v13) of the rendered sheet. The implementation must handle both. |
| 72 | +- No settings or configuration UI is needed for this feature. |
0 commit comments