0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added capture of product card image width/height

refs https://github.com/TryGhost/Team/issues/1873

- the code for storing the image width/height in the card payload was commented out
- uncommented and renamed to match the payload attr names
This commit is contained in:
Kevin Ansfield 2022-09-02 14:44:37 +01:00
parent 594e2ccb08
commit 0152eeb600

View file

@ -229,8 +229,8 @@ export default class KoenigCardProductComponent extends Component {
let imageElem = new Image();
imageElem.onload = () => {
// store width/height for use later to avoid saving an image card with no `src`
this._imageWidth = imageElem.naturalWidth;
this._imageHeight = imageElem.naturalHeight;
this._productImageWidth = imageElem.naturalWidth;
this._productImageHeight = imageElem.naturalHeight;
};
imageElem.src = url;
}
@ -240,14 +240,14 @@ export default class KoenigCardProductComponent extends Component {
resetSrcs() {
// this.set('previewSrc', null);
this.previewSrc = null;
// this._imageWidth = null;
// this._imageHeight = null;
this._productImageWidth = null;
this._productImageHeight = null;
// create undo snapshot when clearing
this.args.editor.run(() => {
this._updatePayloadAttr('productImageSrc', null);
// this._updatePayloadAttr('width', null);
// this._updatePayloadAttr('height', null);
this._updatePayloadAttr('productImageWidth', null);
this._updatePayloadAttr('productImageHeight', null);
});
}
@ -258,12 +258,12 @@ export default class KoenigCardProductComponent extends Component {
// create undo snapshot when image finishes uploading
this.args.editor.run(() => {
this._updatePayloadAttr('productImageSrc', image.url);
if (this._imageWidth && this._imageHeight) {
// this._updatePayloadAttr('width', this._imageWidth);
// this._updatePayloadAttr('height', this._imageHeight);
if (this._productImageWidth && this._productImageHeight) {
this._updatePayloadAttr('productImageWidth', this._productImageWidth);
this._updatePayloadAttr('productImageHeight', this._productImageHeight);
}
this._imageWidth = null;
this._imageHeight = null;
this._productImageWidth = null;
this._productImageHeight = null;
});
}