Inez has uploaded a new change for review. https://gerrit.wikimedia.org/r/70784
Change subject: Revert "(WIP) Cleanup for handling image size" ...................................................................... Revert "(WIP) Cleanup for handling image size" This reverts commit 10a271a82adbf3462d37c6e82939102fc2d4daa1. Change-Id: Id95de48c956dcb9ad6dd62f81bee6ce68d793cb0 --- M js/lib/ext.core.LinkHandler.js M js/lib/mediawiki.WikitextSerializer.js 2 files changed, 26 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid refs/changes/84/70784/1 diff --git a/js/lib/ext.core.LinkHandler.js b/js/lib/ext.core.LinkHandler.js index 037cad5..23652a8 100644 --- a/js/lib/ext.core.LinkHandler.js +++ b/js/lib/ext.core.LinkHandler.js @@ -444,12 +444,10 @@ function handleDims( height, width, info, dataAttribs ) { if ( info.height ) { height = info.height; - dataAttribs.img.h = height; } if ( info.width ) { width = info.width; - dataAttribs.img.w = width; } if ( info.thumburl && info.thumbheight ) { @@ -459,7 +457,8 @@ if ( info.thumburl && info.thumbwidth ) { width = info.thumbwidth; } - + dataAttribs.img.h = height; + dataAttribs.img.w = width; return { h: height, w: width diff --git a/js/lib/mediawiki.WikitextSerializer.js b/js/lib/mediawiki.WikitextSerializer.js index e405f63..a350505 100644 --- a/js/lib/mediawiki.WikitextSerializer.js +++ b/js/lib/mediawiki.WikitextSerializer.js @@ -1105,6 +1105,13 @@ } break; + case 'size': + cb( optName.replace( + '$1', + optVal + 'x' + optVal + ) ); + break; + case 'width': val = DU.getAttributeShadowInfo( imgnode, 'width' ); @@ -1153,6 +1160,17 @@ } } return false; +}; + +WSP.removeOpt = function ( opts, optName ) { + var ix; + + for ( ix = 0; ix < opts.length; ix++ ) { + if ( opts[ix].ck === optName ) { + opts = opts.splice( ix, 1 ); + return; + } + } }; // XXX: This should probably be refactored. -rsmith @@ -1341,22 +1359,16 @@ htAttr = imgnode.getAttribute( 'height' ); wdAttr = imgnode.getAttribute( 'width' ); - if ( htAttr && !this.hasOpt( opts, 'height' ) ) { + if ( dp.img.h != htAttr || dp.img.w != wdAttr ) { + this.removeOpt( opts, 'height' ); + this.removeOpt( opts, 'width' ); + dp.img.htset = true; - - opts.push( { - ck: 'height', - v: 'x' + htAttr, - ak: mwAliases.img_width.last() - } ); - } - - if ( wdAttr && !this.hasOpt( opts, 'width' ) ) { dp.img.wdset = true; opts.push( { - ck: 'width', - v: wdAttr, + ck: 'size', + v: Math.max( htAttr, wdAttr ), ak: mwAliases.img_width.last() } ); } -- To view, visit https://gerrit.wikimedia.org/r/70784 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id95de48c956dcb9ad6dd62f81bee6ce68d793cb0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Parsoid Gerrit-Branch: master Gerrit-Owner: Inez <i...@wikia-inc.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits