3 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * A query action to get image information and upload history.
28 class ApiQueryImageInfo
extends ApiQueryBase
{
29 const TRANSFORM_LIMIT
= 50;
30 private static $transformCount = 0;
32 public function __construct( ApiQuery
$query, $moduleName, $prefix = 'ii' ) {
33 // We allow a subclass to override the prefix, to create a related API
34 // module. Some other parts of MediaWiki construct this with a null
35 // $prefix, which used to be ignored when this only took two arguments
36 if ( is_null( $prefix ) ) {
39 parent
::__construct( $query, $moduleName, $prefix );
42 public function execute() {
43 $params = $this->extractRequestParams();
45 $prop = array_flip( $params['prop'] );
47 $scale = $this->getScale( $params );
50 'version' => $params['metadataversion'],
51 'language' => $params['extmetadatalanguage'],
52 'multilang' => $params['extmetadatamultilang'],
53 'extmetadatafilter' => $params['extmetadatafilter'],
54 'revdelUser' => $this->getUser(),
57 if ( isset( $params['badfilecontexttitle'] ) ) {
58 $badFileContextTitle = Title
::newFromText( $params['badfilecontexttitle'] );
59 if ( !$badFileContextTitle ) {
60 $this->dieUsage( 'Invalid title in badfilecontexttitle parameter', 'invalid-title' );
63 $badFileContextTitle = false;
66 $pageIds = $this->getPageSet()->getGoodAndMissingTitlesByNamespace();
67 if ( !empty( $pageIds[NS_FILE
] ) ) {
68 $titles = array_keys( $pageIds[NS_FILE
] );
69 asort( $titles ); // Ensure the order is always the same
72 if ( !is_null( $params['continue'] ) ) {
73 $cont = explode( '|', $params['continue'] );
74 $this->dieContinueUsageIf( count( $cont ) != 2 );
75 $fromTitle = strval( $cont[0] );
76 $fromTimestamp = $cont[1];
77 // Filter out any titles before $fromTitle
78 foreach ( $titles as $key => $title ) {
79 if ( $title < $fromTitle ) {
80 unset( $titles[$key] );
87 $user = $this->getUser();
88 $findTitles = array_map( function ( $title ) use ( $user ) {
95 if ( $params['localonly'] ) {
96 $images = RepoGroup
::singleton()->getLocalRepo()->findFiles( $findTitles );
98 $images = RepoGroup
::singleton()->findFiles( $findTitles );
101 $result = $this->getResult();
102 foreach ( $titles as $title ) {
104 $pageId = $pageIds[NS_FILE
][$title];
105 $start = $title === $fromTitle ?
$fromTimestamp : $params['start'];
107 if ( !isset( $images[$title] ) ) {
108 if ( isset( $prop['uploadwarning'] ) ||
isset( $prop['badfile'] ) ) {
109 // uploadwarning and badfile need info about non-existing files
110 $images[$title] = wfLocalFile( $title );
111 // Doesn't exist, so set an empty image repository
112 $info['imagerepository'] = '';
115 [ 'query', 'pages', intval( $pageId ) ],
116 'imagerepository', ''
118 // The above can't fail because it doesn't increase the result size
123 /** @var File $img */
124 $img = $images[$title];
126 if ( self
::getTransformCount() >= self
::TRANSFORM_LIMIT
) {
127 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
128 // See the 'the user is screwed' comment below
129 $this->setContinueEnumParameter( 'start',
130 $start !== null ?
$start : wfTimestamp( TS_ISO_8601
, $img->getTimestamp() )
133 $this->setContinueEnumParameter( 'continue',
134 $this->getContinueStr( $img, $start ) );
139 if ( !isset( $info['imagerepository'] ) ) {
140 $info['imagerepository'] = $img->getRepoName();
142 if ( isset( $prop['badfile'] ) ) {
143 $info['badfile'] = (bool)wfIsBadImage( $title, $badFileContextTitle );
146 $fit = $result->addValue( [ 'query', 'pages' ], intval( $pageId ), $info );
148 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
149 // The user is screwed. imageinfo can't be solely
150 // responsible for exceeding the limit in this case,
151 // so set a query-continue that just returns the same
152 // thing again. When the violating queries have been
153 // out-continued, the result will get through
154 $this->setContinueEnumParameter( 'start',
155 $start !== null ?
$start : wfTimestamp( TS_ISO_8601
, $img->getTimestamp() )
158 $this->setContinueEnumParameter( 'continue',
159 $this->getContinueStr( $img, $start ) );
164 // Check if we can make the requested thumbnail, and get transform parameters.
165 $finalThumbParams = $this->mergeThumbParams( $img, $scale, $params['urlparam'] );
167 // Get information about the current version first
168 // Check that the current version is within the start-end boundaries
171 ( is_null( $start ) ||
$img->getTimestamp() <= $start ) &&
172 ( is_null( $params['end'] ) ||
$img->getTimestamp() >= $params['end'] )
176 $fit = $this->addPageSubItem( $pageId,
177 static::getInfo( $img, $prop, $result,
178 $finalThumbParams, $opts
182 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
183 // See the 'the user is screwed' comment above
184 $this->setContinueEnumParameter( 'start',
185 wfTimestamp( TS_ISO_8601
, $img->getTimestamp() ) );
187 $this->setContinueEnumParameter( 'continue',
188 $this->getContinueStr( $img ) );
194 // Now get the old revisions
195 // Get one more to facilitate query-continue functionality
196 $count = ( $gotOne ?
1 : 0 );
197 $oldies = $img->getHistory( $params['limit'] - $count +
1, $start, $params['end'] );
198 /** @var File $oldie */
199 foreach ( $oldies as $oldie ) {
200 if ( ++
$count > $params['limit'] ) {
201 // We've reached the extra one which shows that there are
202 // additional pages to be had. Stop here...
203 // Only set a query-continue if there was only one title
204 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
205 $this->setContinueEnumParameter( 'start',
206 wfTimestamp( TS_ISO_8601
, $oldie->getTimestamp() ) );
210 $fit = self
::getTransformCount() < self
::TRANSFORM_LIMIT
&&
211 $this->addPageSubItem( $pageId,
212 static::getInfo( $oldie, $prop, $result,
213 $finalThumbParams, $opts
217 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
218 $this->setContinueEnumParameter( 'start',
219 wfTimestamp( TS_ISO_8601
, $oldie->getTimestamp() ) );
221 $this->setContinueEnumParameter( 'continue',
222 $this->getContinueStr( $oldie ) );
235 * From parameters, construct a 'scale' array
236 * @param array $params Parameters passed to api.
237 * @return array|null Key-val array of 'width' and 'height', or null
239 public function getScale( $params ) {
240 if ( $params['urlwidth'] != -1 ) {
242 $scale['width'] = $params['urlwidth'];
243 $scale['height'] = $params['urlheight'];
244 } elseif ( $params['urlheight'] != -1 ) {
245 // Height is specified but width isn't
246 // Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
248 $scale['height'] = $params['urlheight'];
250 if ( $params['urlparam'] ) {
251 // Audio files might not have a width/height.
261 /** Validate and merge scale parameters with handler thumb parameters, give error if invalid.
263 * We do this later than getScale, since we need the image
264 * to know which handler, since handlers can make their own parameters.
265 * @param File $image Image that params are for.
266 * @param array $thumbParams Thumbnail parameters from getScale
267 * @param string $otherParams String of otherParams (iiurlparam).
268 * @return array Array of parameters for transform.
270 protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
271 if ( $thumbParams === null ) {
272 // No scaling requested
275 if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
276 // We want to limit only by height in this situation, so pass the
277 // image's full width as the limiting width. But some file types
278 // don't have a width of their own, so pick something arbitrary so
279 // thumbnailing the default icon works.
280 if ( $image->getWidth() <= 0 ) {
281 $thumbParams['width'] = max( $this->getConfig()->get( 'ThumbLimits' ) );
283 $thumbParams['width'] = $image->getWidth();
287 if ( !$otherParams ) {
288 $this->checkParameterNormalise( $image, $thumbParams );
291 $p = $this->getModulePrefix();
293 $h = $image->getHandler();
295 $this->addWarning( [ 'apiwarn-nothumb-noimagehandler', wfEscapeWikiText( $image->getName() ) ] );
300 $paramList = $h->parseParamString( $otherParams );
302 // Just set a warning (instead of dieUsage), as in many cases
303 // we could still render the image using width and height parameters,
304 // and this type of thing could happen between different versions of
306 $this->addWarning( [ 'apiwarn-badurlparam', $p, wfEscapeWikiText( $image->getName() ) ] );
307 $this->checkParameterNormalise( $image, $thumbParams );
311 if ( isset( $paramList['width'] ) && isset( $thumbParams['width'] ) ) {
312 if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
314 [ 'apiwarn-urlparamwidth', $p, $paramList['width'], $thumbParams['width'] ]
319 foreach ( $paramList as $name => $value ) {
320 if ( !$h->validateParam( $name, $value ) ) {
322 [ 'apierror-invalidurlparam', $p, wfEscapeWikiText( $name ), wfEscapeWikiText( $value ) ]
327 $finalParams = $thumbParams +
$paramList;
328 $this->checkParameterNormalise( $image, $finalParams );
333 * Verify that the final image parameters can be normalised.
335 * This doesn't use the normalised parameters, since $file->transform
336 * expects the pre-normalised parameters, but doing the normalisation
337 * allows us to catch certain error conditions early (such as missing
338 * required parameter).
341 * @param array $finalParams List of parameters to transform image with
343 protected function checkParameterNormalise( $image, $finalParams ) {
344 $h = $image->getHandler();
348 // Note: normaliseParams modifies the array in place, but we aren't interested
349 // in the actual normalised version, only if we can actually normalise them,
350 // so we use the functions scope to throw away the normalisations.
351 if ( !$h->normaliseParams( $image, $finalParams ) ) {
352 $this->dieWithError( [ 'apierror-urlparamnormal', wfEscapeWikiText( $image->getName() ) ] );
357 * Get result information for an image revision
360 * @param array $prop Array of properties to get (in the keys)
361 * @param ApiResult $result
362 * @param array $thumbParams Containing 'width' and 'height' items, or null
363 * @param array|bool|string $opts Options for data fetching.
364 * This is an array consisting of the keys:
365 * 'version': The metadata version for the metadata option
366 * 'language': The language for extmetadata property
367 * 'multilang': Return all translations in extmetadata property
368 * 'revdelUser': User to use when checking whether to show revision-deleted fields.
369 * @return array Result array
371 public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
376 if ( !$opts ||
is_string( $opts ) ) {
378 'version' => $opts ?
: 'latest',
379 'language' => $wgContLang,
380 'multilang' => false,
381 'extmetadatafilter' => [],
382 'revdelUser' => null,
385 $version = $opts['version'];
387 ApiResult
::META_TYPE
=> 'assoc',
389 // Timestamp is shown even if the file is revdelete'd in interface
391 if ( isset( $prop['timestamp'] ) ) {
392 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $file->getTimestamp() );
395 // Handle external callers who don't pass revdelUser
396 if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
397 $revdelUser = $opts['revdelUser'];
398 $canShowField = function ( $field ) use ( $file, $revdelUser ) {
399 return $file->userCan( $field, $revdelUser );
402 $canShowField = function ( $field ) use ( $file ) {
403 return !$file->isDeleted( $field );
407 $user = isset( $prop['user'] );
408 $userid = isset( $prop['userid'] );
410 if ( $user ||
$userid ) {
411 if ( $file->isDeleted( File
::DELETED_USER
) ) {
412 $vals['userhidden'] = true;
415 if ( $canShowField( File
::DELETED_USER
) ) {
417 $vals['user'] = $file->getUser();
420 $vals['userid'] = $file->getUser( 'id' );
422 if ( !$file->getUser( 'id' ) ) {
423 $vals['anon'] = true;
428 // This is shown even if the file is revdelete'd in interface
430 if ( isset( $prop['size'] ) ||
isset( $prop['dimensions'] ) ) {
431 $vals['size'] = intval( $file->getSize() );
432 $vals['width'] = intval( $file->getWidth() );
433 $vals['height'] = intval( $file->getHeight() );
435 $pageCount = $file->pageCount();
436 if ( $pageCount !== false ) {
437 $vals['pagecount'] = $pageCount;
440 // length as in how many seconds long a video is.
441 $length = $file->getLength();
443 // Call it duration, because "length" can be ambiguous.
444 $vals['duration'] = (float)$length;
448 $pcomment = isset( $prop['parsedcomment'] );
449 $comment = isset( $prop['comment'] );
451 if ( $pcomment ||
$comment ) {
452 if ( $file->isDeleted( File
::DELETED_COMMENT
) ) {
453 $vals['commenthidden'] = true;
456 if ( $canShowField( File
::DELETED_COMMENT
) ) {
458 $vals['parsedcomment'] = Linker
::formatComment(
459 $file->getDescription( File
::RAW
), $file->getTitle() );
462 $vals['comment'] = $file->getDescription( File
::RAW
);
467 $canonicaltitle = isset( $prop['canonicaltitle'] );
468 $url = isset( $prop['url'] );
469 $sha1 = isset( $prop['sha1'] );
470 $meta = isset( $prop['metadata'] );
471 $extmetadata = isset( $prop['extmetadata'] );
472 $commonmeta = isset( $prop['commonmetadata'] );
473 $mime = isset( $prop['mime'] );
474 $mediatype = isset( $prop['mediatype'] );
475 $archive = isset( $prop['archivename'] );
476 $bitdepth = isset( $prop['bitdepth'] );
477 $uploadwarning = isset( $prop['uploadwarning'] );
479 if ( $uploadwarning ) {
480 $vals['html'] = SpecialUpload
::getExistsWarning( UploadBase
::getExistsWarning( $file ) );
483 if ( $file->isDeleted( File
::DELETED_FILE
) ) {
484 $vals['filehidden'] = true;
488 if ( $anyHidden && $file->isDeleted( File
::DELETED_RESTRICTED
) ) {
489 $vals['suppressed'] = true;
492 if ( !$canShowField( File
::DELETED_FILE
) ) {
493 // Early return, tidier than indenting all following things one level
497 if ( $canonicaltitle ) {
498 $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
502 if ( $file->exists() ) {
503 if ( !is_null( $thumbParams ) ) {
504 $mto = $file->transform( $thumbParams );
505 self
::$transformCount++
;
506 if ( $mto && !$mto->isError() ) {
507 $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT
);
509 // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted
510 // thumbnail sizes for the thumbnail actual size
511 if ( $mto->getUrl() !== $file->getUrl() ) {
512 $vals['thumbwidth'] = intval( $mto->getWidth() );
513 $vals['thumbheight'] = intval( $mto->getHeight() );
515 $vals['thumbwidth'] = intval( $file->getWidth() );
516 $vals['thumbheight'] = intval( $file->getHeight() );
519 if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
520 list( , $mime ) = $file->getHandler()->getThumbType(
521 $mto->getExtension(), $file->getMimeType(), $thumbParams );
522 $vals['thumbmime'] = $mime;
524 } elseif ( $mto && $mto->isError() ) {
525 $vals['thumberror'] = $mto->toText();
528 $vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT
);
530 $vals['filemissing'] = true;
532 $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT
);
534 $shortDescriptionUrl = $file->getDescriptionShortUrl();
535 if ( $shortDescriptionUrl !== null ) {
536 $vals['descriptionshorturl'] = wfExpandUrl( $shortDescriptionUrl, PROTO_CURRENT
);
541 $vals['sha1'] = Wikimedia\base_convert
( $file->getSha1(), 36, 16, 40 );
545 Wikimedia\
suppressWarnings();
546 $metadata = unserialize( $file->getMetadata() );
547 Wikimedia\restoreWarnings
();
548 if ( $metadata && $version !== 'latest' ) {
549 $metadata = $file->convertMetadataVersion( $metadata, $version );
551 $vals['metadata'] = $metadata ?
static::processMetaData( $metadata, $result ) : null;
554 $metaArray = $file->getCommonMetaArray();
555 $vals['commonmetadata'] = $metaArray ?
static::processMetaData( $metaArray, $result ) : [];
558 if ( $extmetadata ) {
559 // Note, this should return an array where all the keys
560 // start with a letter, and all the values are strings.
561 // Thus there should be no issue with format=xml.
562 $format = new FormatMetadata
;
563 $format->setSingleLanguage( !$opts['multilang'] );
564 $format->getContext()->setLanguage( $opts['language'] );
565 $extmetaArray = $format->fetchExtendedMetadata( $file );
566 if ( $opts['extmetadatafilter'] ) {
567 $extmetaArray = array_intersect_key(
568 $extmetaArray, array_flip( $opts['extmetadatafilter'] )
571 $vals['extmetadata'] = $extmetaArray;
575 $vals['mime'] = $file->getMimeType();
579 $vals['mediatype'] = $file->getMediaType();
582 if ( $archive && $file->isOld() ) {
583 $vals['archivename'] = $file->getArchiveName();
587 $vals['bitdepth'] = $file->getBitDepth();
594 * Get the count of image transformations performed
596 * If this is >= TRANSFORM_LIMIT, you should probably stop processing images.
600 static function getTransformCount() {
601 return self
::$transformCount;
606 * @param array $metadata
607 * @param ApiResult $result
610 public static function processMetaData( $metadata, $result ) {
612 if ( is_array( $metadata ) ) {
613 foreach ( $metadata as $key => $value ) {
616 ApiResult
::META_BC_BOOLS
=> [ 'value' ],
618 if ( is_array( $value ) ) {
619 $r['value'] = static::processMetaData( $value, $result );
621 $r['value'] = $value;
626 ApiResult
::setIndexedTagName( $retval, 'metadata' );
631 public function getCacheMode( $params ) {
632 if ( $this->userCanSeeRevDel() ) {
641 * @param null|string $start
644 protected function getContinueStr( $img, $start = null ) {
645 if ( $start === null ) {
646 $start = $img->getTimestamp();
649 return $img->getOriginalTitle()->getDBkey() . '|' . $start;
652 public function getAllowedParams() {
657 ApiBase
::PARAM_ISMULTI
=> true,
658 ApiBase
::PARAM_DFLT
=> 'timestamp|user',
659 ApiBase
::PARAM_TYPE
=> static::getPropertyNames(),
660 ApiBase
::PARAM_HELP_MSG_PER_VALUE
=> static::getPropertyMessages(),
663 ApiBase
::PARAM_TYPE
=> 'limit',
664 ApiBase
::PARAM_DFLT
=> 1,
665 ApiBase
::PARAM_MIN
=> 1,
666 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
667 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
670 ApiBase
::PARAM_TYPE
=> 'timestamp'
673 ApiBase
::PARAM_TYPE
=> 'timestamp'
676 ApiBase
::PARAM_TYPE
=> 'integer',
677 ApiBase
::PARAM_DFLT
=> -1,
678 ApiBase
::PARAM_HELP_MSG
=> [
679 'apihelp-query+imageinfo-param-urlwidth',
680 self
::TRANSFORM_LIMIT
,
684 ApiBase
::PARAM_TYPE
=> 'integer',
685 ApiBase
::PARAM_DFLT
=> -1
687 'metadataversion' => [
688 ApiBase
::PARAM_TYPE
=> 'string',
689 ApiBase
::PARAM_DFLT
=> '1',
691 'extmetadatalanguage' => [
692 ApiBase
::PARAM_TYPE
=> 'string',
693 ApiBase
::PARAM_DFLT
=> $wgContLang->getCode(),
695 'extmetadatamultilang' => [
696 ApiBase
::PARAM_TYPE
=> 'boolean',
697 ApiBase
::PARAM_DFLT
=> false,
699 'extmetadatafilter' => [
700 ApiBase
::PARAM_TYPE
=> 'string',
701 ApiBase
::PARAM_ISMULTI
=> true,
704 ApiBase
::PARAM_DFLT
=> '',
705 ApiBase
::PARAM_TYPE
=> 'string',
707 'badfilecontexttitle' => [
708 ApiBase
::PARAM_TYPE
=> 'string',
711 ApiBase
::PARAM_HELP_MSG
=> 'api-help-param-continue',
713 'localonly' => false,
718 * Returns all possible parameters to iiprop
720 * @param array $filter List of properties to filter out
723 public static function getPropertyNames( $filter = [] ) {
724 return array_keys( static::getPropertyMessages( $filter ) );
728 * Returns messages for all possible parameters to iiprop
730 * @param array $filter List of properties to filter out
733 public static function getPropertyMessages( $filter = [] ) {
734 return array_diff_key(
736 'timestamp' => 'apihelp-query+imageinfo-paramvalue-prop-timestamp',
737 'user' => 'apihelp-query+imageinfo-paramvalue-prop-user',
738 'userid' => 'apihelp-query+imageinfo-paramvalue-prop-userid',
739 'comment' => 'apihelp-query+imageinfo-paramvalue-prop-comment',
740 'parsedcomment' => 'apihelp-query+imageinfo-paramvalue-prop-parsedcomment',
741 'canonicaltitle' => 'apihelp-query+imageinfo-paramvalue-prop-canonicaltitle',
742 'url' => 'apihelp-query+imageinfo-paramvalue-prop-url',
743 'size' => 'apihelp-query+imageinfo-paramvalue-prop-size',
744 'dimensions' => 'apihelp-query+imageinfo-paramvalue-prop-dimensions',
745 'sha1' => 'apihelp-query+imageinfo-paramvalue-prop-sha1',
746 'mime' => 'apihelp-query+imageinfo-paramvalue-prop-mime',
747 'thumbmime' => 'apihelp-query+imageinfo-paramvalue-prop-thumbmime',
748 'mediatype' => 'apihelp-query+imageinfo-paramvalue-prop-mediatype',
749 'metadata' => 'apihelp-query+imageinfo-paramvalue-prop-metadata',
750 'commonmetadata' => 'apihelp-query+imageinfo-paramvalue-prop-commonmetadata',
751 'extmetadata' => 'apihelp-query+imageinfo-paramvalue-prop-extmetadata',
752 'archivename' => 'apihelp-query+imageinfo-paramvalue-prop-archivename',
753 'bitdepth' => 'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
754 'uploadwarning' => 'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
755 'badfile' => 'apihelp-query+imageinfo-paramvalue-prop-badfile',
757 array_flip( $filter )
762 * Returns array key value pairs of properties and their descriptions
764 * @deprecated since 1.25
765 * @param string $modulePrefix
768 private static function getProperties( $modulePrefix = '' ) {
770 'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
771 'user' => ' user - Adds the user who uploaded the image version',
772 'userid' => ' userid - Add the user ID that uploaded the image version',
773 'comment' => ' comment - Comment on the version',
774 'parsedcomment' => ' parsedcomment - Parse the comment on the version',
775 'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
776 'url' => ' url - Gives URL to the image and the description page',
777 'size' => ' size - Adds the size of the image in bytes, ' .
778 'its height and its width. Page count and duration are added if applicable',
779 'dimensions' => ' dimensions - Alias for size', // B/C with Allimages
780 'sha1' => ' sha1 - Adds SHA-1 hash for the image',
781 'mime' => ' mime - Adds MIME type of the image',
782 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
783 ' (requires url and param ' . $modulePrefix . 'urlwidth)',
784 'mediatype' => ' mediatype - Adds the media type of the image',
785 'metadata' => ' metadata - Lists Exif metadata for the version of the image',
786 'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
787 'for the version of the image',
788 'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
789 'from multiple sources. Results are HTML formatted.',
790 'archivename' => ' archivename - Adds the file name of the archive ' .
791 'version for non-latest versions',
792 'bitdepth' => ' bitdepth - Adds the bit depth of the version',
793 'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
794 'get information about an existing file. Not intended for use outside MediaWiki core',
799 * Returns the descriptions for the properties provided by getPropertyNames()
801 * @deprecated since 1.25
802 * @param array $filter List of properties to filter out
803 * @param string $modulePrefix
806 public static function getPropertyDescriptions( $filter = [], $modulePrefix = '' ) {
808 [ 'What image information to get:' ],
809 array_values( array_diff_key( static::getProperties( $modulePrefix ), array_flip( $filter ) ) )
813 protected function getExamplesMessages() {
815 'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
816 => 'apihelp-query+imageinfo-example-simple',
817 'action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
818 'iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url'
819 => 'apihelp-query+imageinfo-example-dated',
823 public function getHelpUrls() {
824 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Imageinfo';