Tim Starling has uploaded a new change for review. https://gerrit.wikimedia.org/r/238657
Change subject: Fix denial of client-side upscaling in thumb and frameless format ...................................................................... Fix denial of client-side upscaling in thumb and frameless format The batch API returns the input width and height even when client-side scaling is done, which I think is the correct policy. However, this does mean that Parsoid needs to handle the case where upscaling is denied itself, instead of relying on the API. Also, mediatype === 'DRAWING' was used as an approximation to mustRender(), which is not accurate. For example, PDFs have media type "OFFICE", see MW's includes/mime.info. Use mediatype != 'BITMAP' in the b/c case, which is more likely to be correct. Also allow the API to provide explicit indication of mustRender. A patch will be forthcoming implementing this in the batch API. This allows Parsoid to match the behaviour of MW, which uses mustRender to determine whether upscaling should be allowed. Bug: T112668 Change-Id: I1500c0f4623928c3be6726cddc33cc31b2b9e00d --- M lib/ext.core.LinkHandler.js 1 file changed, 24 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/57/238657/1 diff --git a/lib/ext.core.LinkHandler.js b/lib/ext.core.LinkHandler.js index 2a8f819..4fdafde 100644 --- a/lib/ext.core.LinkHandler.js +++ b/lib/ext.core.LinkHandler.js @@ -1057,9 +1057,15 @@ var format = getFormat(opts); var size = handleSize(info); - var scalable = info.mediatype === 'DRAWING'; - // client-side upscaling for "unspecified format" (including 'border') - if ((scalable || !format) && info.height && info.width) { + var mustRender; + if (info.mustRender !== undefined) { + mustRender = info.mustRender; + } else { + mustRender = info.mediatype !== 'BITMAP'; + } + // Handle client-side upscaling (including 'border') + if (info.height && info.width) { + // Calculate the scaling ratio from the user-specified width and height var ratio = null; if (opts.size.v.height) { ratio = opts.size.v.height / info.height; @@ -1068,9 +1074,22 @@ var r = opts.size.v.width / info.width; ratio = (ratio === null || r < ratio) ? r : ratio; } + if (ratio !== null && ratio > 1) { - size.height = Math.round(info.height * ratio); - size.width = Math.round(info.width * ratio); + // If the user requested upscaling, then this is denied in the thumbnail + // and frameless format, except for files with mustRender. + if (!mustRender && (format === 'thumbnail' || format === 'frameless')) { + // Upscaling denied + size.height = info.height; + size.width = info.width; + } else { + // Upscaling allowed + // In the batch API, these will already be correct, but the non-batch + // API returns the source width and height whenever client-side scaling + // is requested. + size.height = Math.round(info.height * ratio); + size.width = Math.round(info.width * ratio); + } } } -- To view, visit https://gerrit.wikimedia.org/r/238657 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1500c0f4623928c3be6726cddc33cc31b2b9e00d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Tim Starling <tstarl...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits