[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/<id-of-the-attachment>'. Now the name of the image will
be added for SEO purposes ('/web/image/<id-of-the-attachment>/<name>').

Also protect URLs with quotes to allow spaces.
This commit is contained in:
Vandan Shah
2017-08-18 11:41:28 +02:00
committed by qsm-odoo
parent 22f7b79221
commit 886c07dabb
2 changed files with 2 additions and 2 deletions
@@ -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', '');
@@ -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();