From 3a2288dc2820e4f097e025100dff4c0254881cf3 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 25 May 2023 14:20:28 +0000 Subject: [PATCH] [FIX] web_editor: fix image cropping not working Since this commit [1], the image cropping feature is no longer functioning properly. The modification of the "activateCropper" function code to remove the use of underscore has resulted in a change in the "data" parameter value passed to the cropper compared to before. This alteration is the cause of the issue. Steps to reproduce the bugs: - Open the homepage in Website edit mode. - Drag and drop a text-image snippet onto the page. - Click on the image in the text-image snippet. - Click on the "Crop Image" button in the image options. - Change the aspect ratio of the image by clicking on the "4:3" button. - Click on the "Apply" button to apply the changes. - Bug: The changes are not being applied. [1]: https://github.com/odoo/odoo/commit/f4f0f783183507df8227b37fe1234c256325df6d task-3339518 closes odoo/odoo#122996 X-original-commit: d42070b6abe5ca65d43ae4f2426619684c7aec4d Signed-off-by: Colin Louis (loco) --- addons/web_editor/static/src/js/editor/image_processing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/image_processing.js b/addons/web_editor/static/src/js/editor/image_processing.js index 0d4996e14f5..97962fef01b 100644 --- a/addons/web_editor/static/src/js/editor/image_processing.js +++ b/addons/web_editor/static/src/js/editor/image_processing.js @@ -408,7 +408,8 @@ async function activateCropper(image, aspectRatio, dataset) { dragMode: 'move', autoCropArea: 1.0, aspectRatio: aspectRatio, - data: Object.values(pick(dataset, ...cropperDataFields)).map((value) => parseFloat(value)), + data: Object.fromEntries(Object.entries(pick(dataset, ...cropperDataFields)) + .map(([key, value]) => [key, parseFloat(value)])), // Can't use 0 because it's falsy and cropperjs will then use its defaults (200x100) minContainerWidth: 1, minContainerHeight: 1,