From 38ac59871ec529092ed4cabc58007d7ec45496ed Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 24 May 2018 13:57:47 +0200 Subject: [PATCH] [FIX] portal, web_editor: keep BS 'img-responsive' *opt-in* Bootstrap 'img-responsive' behavior was opt-in for a reason but commit https://github.com/odoo/odoo/commit/f79b00c3b71e02f73537cb17285a6902fc0906b5 tried to defy that anyway. This would break existing client databases ... or at least our odoo.com. This commit adds the img-responsive class for *new* *editor* images (still with inline-block display), preventing breaking libraries or custom (prod) images. --- addons/portal/static/src/less/portal.less | 7 ++++--- addons/web_editor/static/src/js/widgets/widgets.js | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/portal/static/src/less/portal.less b/addons/portal/static/src/less/portal.less index 0e34d305fb5..9b62e37121b 100644 --- a/addons/portal/static/src/less/portal.less +++ b/addons/portal/static/src/less/portal.less @@ -152,9 +152,10 @@ img, .media_iframe_video, .o_image { margin-right: @grid-gutter-width / 2; } } -img { - // Make all images responsive by default but with inline-block display - .img-responsive(inline-block); +img.o_we_custom_image { + // Images added with the editor are .img-responsive by default but should + // still behave like inline content. + display: inline-block; } // Others diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index b63568ff0bd..51ff585d200 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -308,7 +308,10 @@ var ImageWidget = MediaWidget.extend({ img.src += _.str.sprintf('?access_token=%s', img.access_token); } if (!self.$media.is('img')) { - self._replaceMedia($('')); + // Note: by default the images receive the bootstrap opt-in + // img-responsive class. We cannot make them all responsive + // by design because of libraries and client databases img. + self._replaceMedia($('', {class: 'img-responsive o_we_custom_image'})); } self.$media.attr('src', img.src);