From 3e70b26f25f1d3f2df891cab22acd563ab9e97cc Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 16 Sep 2015 14:05:31 +0200 Subject: [PATCH] [FIX] website_mail: outlook and image size Office Outlook doesn't take into account the [style] attribute, and it doesn't manage width/height in percent value. This commit set width/heigth attribute in pixels and also always set the width/height in style attribute (keeping them in the original unit and setting them to auto if not present). Thus if the mail application doesn't support the style attribute, the pixels fixed size are used, else the original size is used. closes #8566 opw-648463 --- .../static/src/js/website_email_designer.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/website_mail/static/src/js/website_email_designer.js b/addons/website_mail/static/src/js/website_email_designer.js index 523cc823ab8..bf5f579167b 100644 --- a/addons/website_mail/static/src/js/website_email_designer.js +++ b/addons/website_mail/static/src/js/website_email_designer.js @@ -303,6 +303,8 @@ setTimeout(function () { self.img_to_font(); self.style_to_class(); + // fix outlook image rendering bug + $("#wrapwrap .o_editable:first").find('img[style*="width"], img[style*="height"]').removeAttr('height width'); }); }, @@ -317,6 +319,14 @@ var theme = ($("#o_left_bar .o_panel_body > div:not(.hidden)").attr("class") || "").replace(/^\s*|\s*o_mail_block[^\s]+\s*|\s*oe_snippet\s*|\s*ui-draggable\s*|\s*$/g, ''); var $theme = $("#wrapwrap .o_editable:first [data-snippet-theme]").removeAttr("data-snippet-theme").removeData("snippet-theme"); $editable.children().first().attr("data-snippet-theme", theme); + // fix outlook image rendering bug + _.each(['width', 'height'], function(attribute) { + $editable.find('img[style*="width"], img[style*="height"]').attr(attribute, function(){ + return $(this)[attribute]() + }).css(attribute, function(){ + return $(this).get(0).style[attribute] || 'auto'; + }); + }); }, // convert font awsome into image font_to_img: function () {