Petr.matas has uploaded a new change for review.
https://gerrit.wikimedia.org/r/273593
Change subject: Thumbnails generated from SVG may be larger than original
......................................................................
Thumbnails generated from SVG may be larger than original
Bug: T128278
Change-Id: I2b10ff28389fd9c99f0703d7ae4ee2d63e0bd000
---
M includes/ApiQueryPageImages.php
1 file changed, 6 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageImages
refs/changes/93/273593/1
diff --git a/includes/ApiQueryPageImages.php b/includes/ApiQueryPageImages.php
index e11ef88..7e968eb 100644
--- a/includes/ApiQueryPageImages.php
+++ b/includes/ApiQueryPageImages.php
@@ -146,13 +146,14 @@
if ( $file ) {
$thumb = $file->transform( array(
'width' => $size, 'height' => $size ) );
if ( $thumb && $thumb->getUrl() ) {
+ $isOriginal = $thumb->getUrl()
=== $file->getUrl();
$vals['thumbnail'] = array(
'source' =>
wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ),
- // You can request a
thumb 1000x larger than the original which will return a Thumb
- // object that will lie
about its size but have the original as an image.
- // Therefore, sanitize
image size.
- 'width' => min(
$thumb->getWidth(), $file->getWidth() ),
- 'height' => min(
$thumb->getHeight(), $file->getHeight() ),
+ // You can request a
thumb 1000x larger than the original
+ // which (in case of
bitmap original) will return a Thumb object
+ // that will lie about
its size but have the original as an image.
+ 'width' => $isOriginal
? $file->getWidth() : $thumb->getWidth(),
+ 'height' => $isOriginal
? $file->getHeight() : $thumb->getHeight(),
);
}
}
--
To view, visit https://gerrit.wikimedia.org/r/273593
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b10ff28389fd9c99f0703d7ae4ee2d63e0bd000
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Petr.matas <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits