From dbea761c29fbbecaf64acc310edb13e2e29d2036 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 13 Jul 2012 17:25:22 +0200 Subject: [PATCH] prop=imageinfo&iiprop=url|thumbmime needs iiurlwidth= A thumb is only generated when prop=url and a urlwidth is given. Adding a hint to param description. list=allpages does not have a urlwidth param and therefor cannot get the thumbmime, adding thumbmime to the filter list to remove it from output Change-Id: Ic1dbdb9b07f6325756058d6a0aa6ea148499fdfb --- includes/api/ApiQueryAllImages.php | 2 +- includes/api/ApiQueryImageInfo.php | 11 ++++++----- includes/api/ApiQueryStashImageInfo.php | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 4ab4d72ad7..3804e3ebd0 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -228,7 +228,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { ); } - private $propertyFilter = array( 'archivename' ); + private $propertyFilter = array( 'archivename', 'thumbmime' ); public function getResultProperties() { return array_merge( diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 4d2d04b589..4a01c2307f 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -491,7 +491,7 @@ class ApiQueryImageInfo extends ApiQueryBase { * * @return array */ - private static function getProperties() { + private static function getProperties( $modulePrefix = '' ) { return array( 'timestamp' => ' timestamp - Adds timestamp for the uploaded version', 'user' => ' user - Adds the user who uploaded the image version', @@ -503,7 +503,8 @@ class ApiQueryImageInfo extends ApiQueryBase { 'dimensions' => ' dimensions - Alias for size', // For backwards compatibility with Allimages 'sha1' => ' sha1 - Adds SHA-1 hash for the image', 'mime' => ' mime - Adds MIME type of the image', - 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail (requires url)', + 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' . + ' (requires url and param ' . $modulePrefix . 'urlwidth)', 'mediatype' => ' mediatype - Adds the media type of the image', 'metadata' => ' metadata - Lists EXIF metadata for the version of the image', 'archivename' => ' archivename - Adds the file name of the archive version for non-latest versions', @@ -518,10 +519,10 @@ class ApiQueryImageInfo extends ApiQueryBase { * * @return array */ - public static function getPropertyDescriptions( $filter = array() ) { + public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) { return array_merge( array( 'What image information to get:' ), - array_values( array_diff_key( self::getProperties(), array_flip( $filter ) ) ) + array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) ) ); } @@ -532,7 +533,7 @@ class ApiQueryImageInfo extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); return array( - 'prop' => self::getPropertyDescriptions(), + 'prop' => self::getPropertyDescriptions( array(), $p ), 'urlwidth' => array( "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.", 'Only the current version of the image can be scaled' ), 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth", diff --git a/includes/api/ApiQueryStashImageInfo.php b/includes/api/ApiQueryStashImageInfo.php index 02484ae9b5..a310d109e6 100644 --- a/includes/api/ApiQueryStashImageInfo.php +++ b/includes/api/ApiQueryStashImageInfo.php @@ -113,7 +113,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { public function getParamDescription() { $p = $this->getModulePrefix(); return array( - 'prop' => self::getPropertyDescriptions( $this->propertyFilter ), + 'prop' => self::getPropertyDescriptions( $this->propertyFilter, $p ), 'filekey' => 'Key that identifies a previous upload that was stashed temporarily.', 'sessionkey' => 'Alias for filekey, for backward compatibility.', 'urlwidth' => "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.", -- 2.20.1