summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-10-05 11:13:50 +0000
committerSamuel Degueldre <sad@odoo.com>2020-10-05 11:13:50 +0000
commit7558dcce791f707e3f3470835133f91ec7ff074f (patch)
treedf7a9ee632644c6b5dccb1fe09cf1e0709c1520f /addons/web_editor/static/src/js/editor
parent8f4b2eefded0e8415b12804f26467f209878cd21 (diff)
[FIX] web_editor: fix background-image urls becoming absolute on drop
With the recent addition of the parallax option on all snippets, background-image urls were being converted from relative to absolute on snippet-drop. This was caused by trying to read the background-image's url and setting it back onto the target, but there is no way to reliably read a background-image url in relative form, so it was returned in absolute form and then written back to the element as is. This commit fixes that by always converting the absolute URL to relative when they are on the same origin as the database. task-2312878 closes odoo/odoo#59098 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js
index 28a344a323c..d8887d67095 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -3420,9 +3420,9 @@ registry.BackgroundOptimize = ImageHandlerOption.extend({
Object.entries(this.$target[0].dataset).forEach(([key, value]) => {
this.img.dataset[key] = value;
});
- const src = new URL(getBgImageURL(this.$target[0]), window.location.origin);
- // Make URL relative because that is how image urls are stored in the database.
- this.img.src = src.origin === window.location.origin && src.pathname;
+ const src = getBgImageURL(this.$target[0]);
+ // Don't set the src if not relative (ie, not local image: cannot be modified)
+ this.img.src = src.startsWith('/') ? src : '';
return await this._super(...arguments);
},