r29932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29931‎ | r29932 | r29933 >
Date:20:17, 18 January 2008
Author:catrope
Status:old
Tags:
Comment:
API: Adding thumbnailing support to prop=imageinfo
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -52,6 +52,10 @@
5353 $fld_size = isset($prop['size']);
5454 $fld_sha1 = isset($prop['sha1']);
5555 $fld_metadata = isset($prop['metadata']);
 56+
 57+ if($params['urlheight'] != -1 && $params['urlwidth'] == -1)
 58+ $this->dieUsage("iiurlheight cannot be used without iiurlwidth", 'iiurlwidth');
 59+ $scale = $params['urlwidth'] != -1;
5660
5761 $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
5862 if (!empty($pageIds[NS_IMAGE])) {
@@ -91,8 +95,13 @@
9296 $vals['width'] = intval($row["{$prefix}_width"]);
9397 $vals['height'] = intval($row["{$prefix}_height"]);
9498 }
95 - if ($fld_url)
96 - $vals['url'] = $isCur ? $img->getURL() : $img->getArchiveUrl($row["oi_archive_name"]);
 99+ if ($fld_url) {
 100+ if($scale && $isCur) {
 101+ $vals['url'] = $img->createThumb($params['urlwidth'], $params['urlheight']);
 102+ } else {
 103+ $vals['url'] = $isCur ? $img->getURL() : $img->getArchiveUrl($row["oi_archive_name"]);
 104+ }
 105+ }
97106 if ($fld_comment)
98107 $vals['comment'] = $row["{$prefix}_description"];
99108
@@ -142,6 +151,14 @@
143152 )
144153 ),
145154 'history' => false,
 155+ 'urlwidth' => array(
 156+ ApiBase :: PARAM_TYPE => 'integer',
 157+ ApiBase :: PARAM_DFLT => -1
 158+ ),
 159+ 'urlheight' => array(
 160+ ApiBase :: PARAM_TYPE => 'integer',
 161+ ApiBase :: PARAM_DFLT => -1
 162+ )
146163 );
147164 }
148165
@@ -149,6 +166,8 @@
150167 return array (
151168 'prop' => 'What image information to get.',
152169 'history' => 'Include upload history',
 170+ 'urlwidth' => 'If iiprop=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.',
 171+ 'urlheight' => 'Similar to iiurlwidth. Cannot be used without iiurlwidth',
153172 );
154173 }
155174
Index: trunk/phase3/RELEASE-NOTES
@@ -440,6 +440,7 @@
441441 * Added action=logout
442442 * Added cascade flag to prop=info&inprop=protections
443443 * Added wlshow parameter to list=watchlist, similar to rcshow (list=recentchanges)
 444+* Added support for image thumbnailing to prop=imageinfo
444445
445446 === Languages updated in 1.12 ===
446447

Status & tagging log