From 8d63e491148fa2e2e5069b6bcc5b673ed3e5767b Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Fri, 9 Feb 2024 13:08:08 +0000 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#153716 X-original-commit: 9d827cc22245a6706d5b6b94ac3c30a3d8cb238b Signed-off-by: Quentin Smetz (qsm) Co-authored-by: qsm-odoo --- .../web_editor/static/src/js/editor/image_processing.js | 8 +++++++- 1 file changed, 7 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 d22552f4407..1308c23b0e0 100644 --- a/addons/web_editor/static/src/js/editor/image_processing.js +++ b/addons/web_editor/static/src/js/editor/image_processing.js @@ -488,7 +488,13 @@ export 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". + // // The "redirect" check is for when it is a redirect image attachment due to // an external URL upload. if (original && original.image_src && !/\/web\/image\/\d+-redirect\//.test(original.image_src)) {