feat: add Edit Image Handler to Actor Sheet

This commit is contained in:
Alexander Minges 2025-07-12 21:51:38 +02:00
parent 6c72605156
commit aa9cbee8b4
Signed by: Athemis
GPG key ID: 31FBDEF92DDB162B
2 changed files with 22 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT
!-- @param @partial-block: Properties to render in the second header row.
--}}
<header class="ds4-actor-header">
<img class="ds4-actor-header__img{{#if editable}} ds4-actor-header__img--editable{{/if}}" src="{{data.img}}" data-edit="img" alt="{{localize 'DS4.ActorImageAltText'}}"
<img class="ds4-actor-header__img{{#if editable}} ds4-actor-header__img--editable{{/if}}" src="{{data.img}}" data-action="editImage" alt="{{localize 'DS4.ActorImageAltText'}}"
title="{{data.name}}" height="100" width="100" />
<div class="ds4-actor-header__data">
<div class="ds4-actor-header__data-row">