Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/117161
Change subject: Enforce width-only default size only on larger images ...................................................................... Enforce width-only default size only on larger images While the documentation is unclear, it seems that the 'thumbsize' in $wgDefaultUserOptions is setting up width limit rather than a general bounding box. Two things are adapted in this fix: * Only resize the image if the image is bigger than default and marked as default size. * Only limit width, even if the image is tall. * Make sure new images follow these rules as well on insertion. Bug: 62293 Change-Id: I37525bf3480bb1da8b0538f9b38576616aabbfa6 --- M modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js M modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js 2 files changed, 7 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/61/117161/1 diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js index 62d0292..8f28a5f 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js @@ -135,18 +135,15 @@ // rather than default MediaWiki configuration dimensions. // We must force local wiki default in edit mode for default // size images. - // FIXME if the image's original size is less than the default size, - // this is wrong. - if ( attributes.width > attributes.height ) { + // Only change the image size to default if the image isn't + // smaller than that defaut size + if ( + attributes.width > defaultSizeBoundingBox + ) { if ( attributes.height !== null ) { - attributes.height = ( attributes.height / attributes.width ) * defaultSizeBoundingBox; + attributes.height = Math.round( ( attributes.height / attributes.width ) * defaultSizeBoundingBox ); } attributes.width = defaultSizeBoundingBox; - } else { - if ( attributes.width !== null ) { - attributes.width = ( attributes.width / attributes.height ) * defaultSizeBoundingBox; - } - attributes.height = defaultSizeBoundingBox; } } } diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js index de7828e..376c946 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js @@ -170,12 +170,9 @@ if ( data.action === 'insert' ) { info = this.item.imageinfo[0]; // Calculate proper size according to default thumb size limit - if ( info.width > info.height ) { + if ( info.width > this.defaultThumbSize ) { thumbwidth = this.defaultThumbSize; thumbheight = Math.round( ( info.height / info.width ) * thumbwidth ); - } else { - thumbheight = this.defaultThumbSize; - thumbwidth = Math.round( ( info.width / info.height ) * thumbheight ); } this.surface.getModel().getFragment().collapseRangeToEnd().insertContent( [ { -- To view, visit https://gerrit.wikimedia.org/r/117161 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I37525bf3480bb1da8b0538f9b38576616aabbfa6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits