Index: trunk/phase3/includes/api/ApiQueryImageInfo.php |
— | — | @@ -52,6 +52,10 @@ |
53 | 53 | $fld_size = isset($prop['size']); |
54 | 54 | $fld_sha1 = isset($prop['sha1']); |
55 | 55 | $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; |
56 | 60 | |
57 | 61 | $pageIds = $this->getPageSet()->getAllTitlesByNamespace(); |
58 | 62 | if (!empty($pageIds[NS_IMAGE])) { |
— | — | @@ -91,8 +95,13 @@ |
92 | 96 | $vals['width'] = intval($row["{$prefix}_width"]); |
93 | 97 | $vals['height'] = intval($row["{$prefix}_height"]); |
94 | 98 | } |
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 | + } |
97 | 106 | if ($fld_comment) |
98 | 107 | $vals['comment'] = $row["{$prefix}_description"]; |
99 | 108 | |
— | — | @@ -142,6 +151,14 @@ |
143 | 152 | ) |
144 | 153 | ), |
145 | 154 | '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 | + ) |
146 | 163 | ); |
147 | 164 | } |
148 | 165 | |
— | — | @@ -149,6 +166,8 @@ |
150 | 167 | return array ( |
151 | 168 | 'prop' => 'What image information to get.', |
152 | 169 | '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', |
153 | 172 | ); |
154 | 173 | } |
155 | 174 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -440,6 +440,7 @@ |
441 | 441 | * Added action=logout |
442 | 442 | * Added cascade flag to prop=info&inprop=protections |
443 | 443 | * Added wlshow parameter to list=watchlist, similar to rcshow (list=recentchanges) |
| 444 | +* Added support for image thumbnailing to prop=imageinfo |
444 | 445 | |
445 | 446 | === Languages updated in 1.12 === |
446 | 447 | |