From fd0c0976c2884939cd3462b2696715897ab8db1d Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 11 Jan 2022 10:09:13 +0000 Subject: [PATCH] [FIX] web_editor: properly convert img dimensions Images sometimes shrunk on conversion because of a parenthesis error in a conditional chain, because dimensions set via element attributes should be preserved, and because the offset height should be used rather than the element height as returned by jQuery. Part-of: odoo/odoo#83233 --- addons/web_editor/static/src/js/backend/convert_inline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index 05533b39707..5c2d0f36215 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -360,9 +360,9 @@ function toInline($editable, cssRules) { // fields). _.each(['width', 'height'], function (attribute) { $editable.find('img').attr(attribute, function () { - return $(this)[attribute](); + return ($(this).attr(attribute)) || (attribute === 'height' && this.offsetHeight) || $(this)[attribute](); }).css(attribute, function () { - return $(this).get(0).style[attribute] || attribute === 'width' ? $(this)[attribute]() + 'px' : ''; + return $(this).attr(attribute); }); });