SVG files display at max resolution

When an svg file is requested, returns the 1024px file and displays at
max possible size

Bug: T71237
Change-Id: I797794d1f9b1aa66cbb9bd9fec57274554292fb1
This commit is contained in:
flutters 2018-11-22 16:17:40 +01:00 committed by Gergő Tisza
parent 957deebfa3
commit 2fad4daa43
2 changed files with 15 additions and 7 deletions

View file

@ -792,9 +792,8 @@
thumbnailPromise,
imagePromise;
if ( originalWidth && width > originalWidth ) {
if ( fileTitle.ext.toLowerCase() !== 'svg' && originalWidth && width > originalWidth ) {
// Do not request images larger than the original image
// This would be possible (but still unwanted) for SVG images
width = originalWidth;
}

View file

@ -562,16 +562,25 @@
} );
QUnit.test( 'Refuse to load too-big thumbnails', function ( assert ) {
var viewer = mw.mmv.testHelpers.getMultimediaViewer(),
intendedWidth = 50,
title = mw.Title.newFromText( 'File:Foobar.svg' );
var title, expectedWidth,
reuestedWidth = 1000,
originalWidth = 50,
viewer = mw.mmv.testHelpers.getMultimediaViewer();
viewer.thumbnailInfoProvider.get = function ( fileTitle, width ) {
assert.strictEqual( width, intendedWidth );
assert.strictEqual( width, expectedWidth );
return $.Deferred().reject();
};
viewer.fetchThumbnail( title, 1000, null, intendedWidth, 60 );
// non-vector should be capped to original size
title = mw.Title.newFromText( 'File:Foobar.png' );
expectedWidth = originalWidth;
viewer.fetchThumbnail( title, reuestedWidth, null, originalWidth, 60 );
// vector images can be aritrarily large
title = mw.Title.newFromText( 'File:Foobar.svg' );
expectedWidth = reuestedWidth;
viewer.fetchThumbnail( title, reuestedWidth, null, originalWidth, 60 );
} );
QUnit.test( 'fetchThumbnail()', function ( assert ) {