feat: add Edit Image Handler to Actor Sheet
This commit is contained in:
parent
6c72605156
commit
aa9cbee8b4
2 changed files with 22 additions and 1 deletions
|
@ -43,6 +43,7 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 {
|
||||||
editeffect: DS4ActorSheet.prototype._onEditEffect,
|
editeffect: DS4ActorSheet.prototype._onEditEffect,
|
||||||
deleteeffect: DS4ActorSheet.prototype._onDeleteEffect,
|
deleteeffect: DS4ActorSheet.prototype._onDeleteEffect,
|
||||||
createeffect: DS4ActorSheet.prototype._onCreateEffect,
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ SPDX-License-Identifier: MIT
|
||||||
!-- @param @partial-block: Properties to render in the second header row.
|
!-- @param @partial-block: Properties to render in the second header row.
|
||||||
--}}
|
--}}
|
||||||
<header class="ds4-actor-header">
|
<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" />
|
title="{{data.name}}" height="100" width="100" />
|
||||||
<div class="ds4-actor-header__data">
|
<div class="ds4-actor-header__data">
|
||||||
<div class="ds4-actor-header__data-row">
|
<div class="ds4-actor-header__data-row">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue