Skip to content

Commit

Permalink
[FIX] web_editor: use media client width as default mediaWidth
Browse files Browse the repository at this point in the history
Previously, when trying to compute the optimized width for an image,
if the mediaWidth option was unspecified, _computeOptimizedWidth would
return NaN, and in all the places where it was specified, it was
specified as 1920 meaning it was essentially useless.

This commit makes the media's clientWidth the default value for
mediaWidth, meaning that if options.mediaWidth is unspecified, the size
of the element in the page (if one exists) is used. This allows the
suggested width to be actually useful, instead of always suggesting
1920. Specifying a mediaWidth in the options overrides this value.

task-2215913

closes odoo#47662

Signed-off-by: Quentin Smetz (qsm) <[email protected]>
  • Loading branch information
sdegueldre committed Mar 16, 2020
1 parent 1968ef1 commit 6445728
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions addons/web_editor/static/src/js/wysiwyg/widgets/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var FileWidget = SearchableMediaWidget.extend({
firstFilters: [],
lastFilters: [],
showQuickUpload: config.isDebug(),
mediaWidth: media && media.clientWidth,
}, options || {});

this.attachments = [];
Expand Down

0 comments on commit 6445728

Please sign in to comment.