prop=imageinfo&iiprop=url|thumbmime needs iiurlwidth=
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 13 Jul 2012 15:25:22 +0000 (17:25 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 13 Jul 2012 15:25:22 +0000 (17:25 +0200)
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
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryStashImageInfo.php

index 4ab4d72..3804e3e 100644 (file)
@@ -228,7 +228,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                );
        }
 
-       private $propertyFilter = array( 'archivename' );
+       private $propertyFilter = array( 'archivename', 'thumbmime' );
 
        public function getResultProperties() {
                return array_merge(
index 4d2d04b..4a01c23 100644 (file)
@@ -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",
index 02484ae..a310d10 100644 (file)
@@ -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.",