[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
This commit is contained in:
Antoine Guenet
2022-01-24 15:09:27 +00:00
committed by David Monjoie
parent e641575150
commit fd0c0976c2
@@ -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);
});
});