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}}