From 886c07dabb636767b80abb8498509d98fc1acf8b Mon Sep 17 00:00:00 2001 From: Vandan Shah Date: Mon, 10 Jul 2017 16:54:29 +0530 Subject: [PATCH] [IMP] web_editor: add image filename at the end of URLs When an image is added thanks to the media dialog, the URL that is used was '/web/image/'. Now the name of the image will be added for SEO purposes ('/web/image//'). Also protect URLs with quotes to allow spaces. --- addons/web_editor/static/src/js/editor/snippets.options.js | 2 +- addons/web_editor/static/src/js/widgets/widgets.js | 2 +- 2 files changed, 2 insertions(+), 2 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 ba4ab0b60ed..afa1b77f3c1 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -833,7 +833,7 @@ registry.background = SnippetOption.extend({ */ background: function (previewMode, value, $li) { if (value && value.length) { - this.$target.css('background-image', 'url(' + value + ')'); + this.$target.css('background-image', 'url(\'' + value + '\')'); this.$target.addClass('oe_img_bg'); } else { this.$target.css('background-image', ''); diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index 5340efb821e..c889fb3d221 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -306,7 +306,7 @@ var ImageDialog = Widget.extend({ return (r.url || r.id); }); _.each(this.records, function (record) { - record.src = record.url || '/web/image/' + record.id; + record.src = record.url || _.str.sprintf('/web/image/%s/%s', record.id, record.name); // Name is added for SEO purposes record.is_document = !(/gif|jpe|jpg|png/.test(record.mimetype)); }); this.display_attachments();