From 402f06379eacae0477a0a7efef6dee4033bc1cc9 Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Fri, 9 Feb 2024 14:08:08 +0100 Subject: [PATCH] [FIX] web_editor: improve comment in loadImageInfo method The goal of this commit is to improve the comment in the `loadImageInfo` method. We decided to retarget [1] to master for a potential merge over there, although it might just get cancelled entirely. We leave the small regression in stable: not being possible to customize an image (filter, optimization, etc) of an image-added-by-url when the URL is actually... an image in a static folder of your own instance's website. This worked in the past but this is kinda a weird use case which has alternatives. Fixing it in stable would be choosing between two possibilities: - Checking that the URL is actually a "local" URL -> this is exactly what we cannot do anymore if we want another bug fix to remain: the updated comment explains why. - Also supporting customizing images added by URL for "external" URL -> this is too risky in stable, that is why [1] will be considered in master only, although it will not be strictly necessary over there since the improvements made with [2]. [1]: https://github.com/odoo/odoo/pull/151858 [2]: https://github.com/odoo/odoo/commit/943944dd249c15de870d6800d89e48d54a422e5a closes odoo/odoo#153438 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: qsm-odoo --- addons/web_editor/static/src/js/editor/image_processing.js | 7 ++++++- 1 file changed, 6 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 93f16d624b113..93aff6c4a940e 100644 --- a/addons/web_editor/static/src/js/editor/image_processing.js +++ b/addons/web_editor/static/src/js/editor/image_processing.js @@ -463,7 +463,12 @@ async function loadImageInfo(img, rpc, attachmentSrc = '') { // If src was an absolute "external" URL, we consider unlikely that its // relative part matches something from the DB and even if it does, nothing // bad happens, besides using this random image as the original when using - // the options, instead of having no option. + // the options, instead of having no option. Note that we do not want to + // check if the image is local or not here as a previous bug converted some + // local (relative src) images to absolute URL... and that before users had + // setup their website domain. That means they can have an absolute URL that + // looks like "https://mycompany.odoo.com/web/image/123" that leads to a + // "local" image even if the domain name is now "mycompany.be". if (original && original.image_src) { img.dataset.originalId = original.id; img.dataset.originalSrc = original.image_src;