From a17cd938640a0597f6a9781bb6b8b4b6abafbded Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 22 Jun 2018 12:58:40 +0200 Subject: [PATCH] [FIX] web_editor: allow recropping a newly cropped image Since https://github.com/odoo/odoo/commit/a473453b3166a381130d9bd6ec4851b9e1ecab26, a newly cropped image gets a base64 src until the user choose to save the page (where we create an attachment for the cropped picture). The problem is that when reentering the crop edition at once... it was not able to be performed because we did not handle base64 images there. This commit solves this and accidentally adds a feature: allow cropping base64 images. --- addons/web_editor/static/src/js/widgets/widgets.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index d7662951999..92ebf9ec4fe 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -1589,10 +1589,10 @@ var CropImageDialog = Dialog.extend({ ]; this.imageData = { imageSrc: src, - originalSrc: src, // the original src for cropped DB images will be fetched later - mimetype: _.str.endsWith(src, '.png') ? 'image/png' : 'image/jpeg', // the mimetype for DB images will be fetched later + originalSrc: this.$media.data('crop:originalSrc') || src, // the original src for cropped DB images will be fetched later + mimetype: this.$media.data('crop:mimetype') || (_.str.endsWith(src, '.png') ? 'image/png' : 'image/jpeg'), // the mimetype for DB images will be fetched later aspectRatio: this.$media.data('aspectRatio') || this.aspectRatioList[0][1], - isExternalImage: src[0] !== '/' && src.indexOf(window.location.host) < 0, + isExternalImage: src.substr(0, 5) !== 'data:' && src[0] !== '/' && src.indexOf(window.location.host) < 0, }; this.options = _.extend({ title: _t("Crop Image"),