From e9c223731daa0b0e716f58c727a5ee1a026abba1 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Wed, 16 Jul 2025 22:33:34 +0200 Subject: [PATCH] fix(item-sheet): enable image editing via file picker --- src/apps/item-sheet.js | 17 +++++++++++++++++ .../sheets/item/components/item-header.hbs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/apps/item-sheet.js b/src/apps/item-sheet.js index 8b8a3966..14e9939e 100644 --- a/src/apps/item-sheet.js +++ b/src/apps/item-sheet.js @@ -32,6 +32,7 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication deleteEffect: DS4ItemSheet.prototype._onDeleteEffect, deleteeffect: DS4ItemSheet.prototype._onDeleteEffect, changeTab: DS4ItemSheet.prototype._onChangeTab, + editImage: DS4ItemSheet.prototype._onEditImage, }, }; @@ -250,7 +251,23 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication } } + /** + * Handle editing the items's image + * @param {Event} event - The triggering event + * @param {HTMLElement} target - The target element + */ + async _onEditImage(event, target) { + const field = target.dataset.field || "img"; + const current = foundry.utils.getProperty(this.item, field); + const fp = new foundry.applications.apps.FilePicker({ + type: "image", + current: current, + callback: (path) => this.item.update({ [field]: path }) + }); + console.log("Editing image..."); + return fp.browse(); + } /** @override */ async _onRender(context, options) { diff --git a/templates/sheets/item/components/item-header.hbs b/templates/sheets/item/components/item-header.hbs index 9eac3872..a89e72b0 100644 --- a/templates/sheets/item/components/item-header.hbs +++ b/templates/sheets/item/components/item-header.hbs @@ -5,7 +5,7 @@ SPDX-License-Identifier: MIT --}}
- {{localize 'DS4.ItemImageAltText'}}

{{lookup config.i18n.itemTypes item.type}}