Matthias Mullie has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/375393 )
Change subject: Don’t pass bigger-than-source-image dimensions to ThumbnailImage
......................................................................
Don’t pass bigger-than-source-image dimensions to ThumbnailImage
Comments in normaliseParams state that we won’t make images bigger
than their source, so this should probably be reflected here.
Result of this would be that thumbs of small images would be smaller:
* file revision history thumbs would shrink if source file is smaller
* [[File:xyz.jpg|500px]] would not be 500px if source file is smaller
* Probably a few other places I haven’t yet looked up…
On the one hand, it doesn’t really make too much sense showing an image
bigger than it is: it’ll just be blurry.
OTOH, there may be aesthetical reasons for doing so?
IDK :)
I don’t really know what direction we want to go with this, so I’m
seeking input here
Bug: T158525
Change-Id: If47990bb8ff0e3c69edf5e8dc25e4d528761961d
---
M includes/api/ApiQueryImageInfo.php
M includes/media/TransformationalImageHandler.php
2 files changed, 9 insertions(+), 17 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/93/375393/1
diff --git a/includes/api/ApiQueryImageInfo.php
b/includes/api/ApiQueryImageInfo.php
index 7b0080e..fea2942 100644
--- a/includes/api/ApiQueryImageInfo.php
+++ b/includes/api/ApiQueryImageInfo.php
@@ -508,16 +508,8 @@
self::$transformCount++;
if ( $mto && !$mto->isError() ) {
$vals['thumburl'] = wfExpandUrl(
$mto->getUrl(), PROTO_CURRENT );
-
- // T25834 - If the URLs are the same,
we haven't resized it, so shouldn't give the wanted
- // thumbnail sizes for the thumbnail
actual size
- if ( $mto->getUrl() !== $file->getUrl()
) {
- $vals['thumbwidth'] = intval(
$mto->getWidth() );
- $vals['thumbheight'] = intval(
$mto->getHeight() );
- } else {
- $vals['thumbwidth'] = intval(
$file->getWidth() );
- $vals['thumbheight'] = intval(
$file->getHeight() );
- }
+ $vals['thumbwidth'] = intval(
$mto->getWidth() );
+ $vals['thumbheight'] = intval(
$mto->getHeight() );
if ( isset( $prop['thumbmime'] ) &&
$file->getHandler() ) {
list( , $mime ) =
$file->getHandler()->getThumbType(
diff --git a/includes/media/TransformationalImageHandler.php
b/includes/media/TransformationalImageHandler.php
index 32208cc..4bdb915 100644
--- a/includes/media/TransformationalImageHandler.php
+++ b/includes/media/TransformationalImageHandler.php
@@ -176,8 +176,8 @@
if ( $flags & self::TRANSFORM_LATER ) {
wfDebug( __METHOD__ . ": Transforming later per
flags.\n" );
$newParams = [
- 'width' => $scalerParams['clientWidth'],
- 'height' => $scalerParams['clientHeight']
+ 'width' => $scalerParams['physicalWidth'],
+ 'height' => $scalerParams['physicalHeight']
];
if ( isset( $params['quality'] ) ) {
$newParams['quality'] = $params['quality'];
@@ -230,7 +230,7 @@
}
// $scaler will return a MediaTransformError on failure, or
false on success.
- // If the scaler is succesful, it will have created a thumbnail
at the destination
+ // If the scaler is successful, it will have created a
thumbnail at the destination
// path.
if ( is_array( $scaler ) && is_callable( $scaler ) ) {
// Allow subclasses to specify their own rendering
methods.
@@ -260,7 +260,7 @@
# Remove the file if a zero-byte thumbnail was created, or if
there was an error
$removed = $this->removeBadFile( $dstPath, (bool)$err );
if ( $err ) {
- # transform returned MediaTransforError
+ # transform returned MediaTransformError
return $err;
} elseif ( $removed ) {
# Thumbnail was zero-byte and had to be removed
@@ -272,8 +272,8 @@
return $mto;
} else {
$newParams = [
- 'width' => $scalerParams['clientWidth'],
- 'height' => $scalerParams['clientHeight']
+ 'width' => $scalerParams['physicalWidth'],
+ 'height' => $scalerParams['physicalHeight']
];
if ( isset( $params['quality'] ) ) {
$newParams['quality'] = $params['quality'];
@@ -320,7 +320,7 @@
abstract protected function getScalerType( $dstPath, $checkDstPath =
true );
/**
- * Get a ThumbnailImage that respresents an image that will be scaled
+ * Get a ThumbnailImage that represents an image that will be scaled
* client side
*
* @param File $image File associated with this thumbnail
--
To view, visit https://gerrit.wikimedia.org/r/375393
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If47990bb8ff0e3c69edf5e8dc25e4d528761961d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits