From 26a6c99eb002d251b8be06d5695d23b24372dba3 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 27 Apr 2021 11:46:05 +0000 Subject: [PATCH] [FIX] web_editor: email receiver see file icon Scenario: - add a file in mass mailing editor => an generic icon (instead of lower version where icon depended on mimetype) is added linking the file - save and send mail => no icon is shown in email received The system is targeting `a[href*="/web/content/"][data-mimetype]:empty` to add real image inside instead of using background-image attribute which is stripped in sanitized. With this commit, data-mimetype is not removed when image processing attributes are removed when a file is inserted. opw-2474053 closes odoo/odoo#70022 X-original-commit: eb3772508ce518ff3f84724eebbe43fd1e040d77 Signed-off-by: Nicolas Lempereur (nle) --- addons/web_editor/static/src/js/wysiwyg/widgets/media.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js index dd0819022ea..ab9622a73b1 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js @@ -451,7 +451,7 @@ var FileWidget = SearchableMediaWidget.extend({ } href += 'unique=' + img.checksum + '&download=true'; this.$media.attr('href', href); - this.$media.addClass('o_image').attr('title', img.name).attr('data-mimetype', img.mimetype); + this.$media.addClass('o_image').attr('title', img.name); } this.$media.attr('alt', img.alt || img.description || ''); @@ -464,6 +464,10 @@ var FileWidget = SearchableMediaWidget.extend({ removeOnImageChangeAttrs.forEach(attr => { delete this.media.dataset[attr]; }); + // Add mimetype for documents + if (!img.image_src) { + this.media.dataset.mimetype = img.mimetype; + } this.media.classList.remove('o_modified_image_to_save'); this.$media.trigger('image_changed'); return this.media;