From aa9cbee8b4bd05447ef4928cc51732fb836e40cb Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Sat, 12 Jul 2025 21:51:38 +0200 Subject: [PATCH] feat: add Edit Image Handler to Actor Sheet --- src/apps/actor/base-sheet.js | 21 +++++++++++++++++++ .../sheets/actor/components/actor-header.hbs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/apps/actor/base-sheet.js b/src/apps/actor/base-sheet.js index a7970fc0..fc6efe27 100644 --- a/src/apps/actor/base-sheet.js +++ b/src/apps/actor/base-sheet.js @@ -43,6 +43,7 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 { editeffect: DS4ActorSheet.prototype._onEditEffect, deleteeffect: DS4ActorSheet.prototype._onDeleteEffect, createeffect: DS4ActorSheet.prototype._onCreateEffect, + editImage: DS4ActorSheet.prototype._onEditImage, }, }; @@ -605,4 +606,24 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 { } } } + + /** + * Handle editing the actor's portrait image + * @param {Event} event - The triggering event + * @param {HTMLElement} target - The target element + */ + async _onEditImage(event, target) { + const attr = "img"; + const current = this.document.img; + + const fp = new FilePicker({ + type: "image", + current: current, + callback: (path) => { + this.document.update({ [attr]: path }); + } + }); + + return fp.browse(); + } } diff --git a/templates/sheets/actor/components/actor-header.hbs b/templates/sheets/actor/components/actor-header.hbs index c6b13c78..8fc9d602 100644 --- a/templates/sheets/actor/components/actor-header.hbs +++ b/templates/sheets/actor/components/actor-header.hbs @@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT !-- @param @partial-block: Properties to render in the second header row. --}}
- {{localize 'DS4.ActorImageAltText'}}