http://www.mediawiki.org/wiki/Special:Code/MediaWiki/83791
Revision: 83791 Author: btongminh Date: 2011-03-12 22:49:31 +0000 (Sat, 12 Mar 2011) Log Message: ----------- (bug 2581, bug 6834) Added links to thumbnail in several resolutions to the file description page. The sizes are set by $wgImageLimits. Not really happy about how it looks, perhaps only the numbers should be linked? See http://www.mediawiki.org/wiki/User:Bryan/Bug_2581 for options. Removed message show-big-image-thumb, added show-big-image-preview, show-big-image-other, show-big-image-size. Modified Paths: -------------- trunk/phase3/RELEASE-NOTES trunk/phase3/includes/ImagePage.php trunk/phase3/languages/messages/MessagesEn.php trunk/phase3/maintenance/language/messages.inc Modified: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES 2011-03-12 22:48:58 UTC (rev 83790) +++ trunk/phase3/RELEASE-NOTES 2011-03-12 22:49:31 UTC (rev 83791) @@ -112,6 +112,8 @@ * (bug 14706) Added support for the Imagick PHP extension. * (bug 18691) Added support for SVG rasterization using the Imagick PHP extension +* (bug 2581, bug 6834) Added links to thumbnail in several resolutions to the + file description page. The sizes are set by $wgImageLimits. === Bug fixes in 1.18 === * (bug 23119) WikiError class and subclasses are now marked as deprecated Modified: trunk/phase3/includes/ImagePage.php =================================================================== --- trunk/phase3/includes/ImagePage.php 2011-03-12 22:48:58 UTC (rev 83790) +++ trunk/phase3/includes/ImagePage.php 2011-03-12 22:49:31 UTC (rev 83791) @@ -360,16 +360,25 @@ # because of rounding. } $msgbig = wfMsgHtml( 'show-big-image' ); - $msgsmall = wfMsgExt( 'show-big-image-thumb', 'parseinline', - $wgLang->formatNum( $width ), - $wgLang->formatNum( $height ) - ); + $otherSizes = array(); + foreach ( $wgImageLimits as $size ) { + if ( $size[0] < $width_orig && $size[1] < $height_orig && + $size[0] != $width && $size[1] != $height ) { + $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] ); + } + } + $msgsmall = wfMessage( 'show-big-image-preview' )-> + rawParams( $this->makeSizeLink( $params, $width, $height ) )-> + parse() . ' ' . + wfMessage( 'show-big-image-other' )-> + rawParams( $wgLang->pipeList( $otherSizes ) )->parse(); } else { # Image is small enough to show full size on image page $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) ); } $params['width'] = $width; + $params['height'] = $height; $thumbnail = $this->displayImg->transform( $params ); $showLink = true; @@ -515,6 +524,30 @@ } } } + + /** + * Creates an thumbnail of specified size and returns an HTML link to it + * @param array $params Scaler parameters + * @param int $width + * @param int $height + */ + private function makeSizeLink( $params, $width, $height ) { + global $wgLang; + + $params['width'] = $width; + $params['height'] = $height; + $thumbnail = $this->displayImg->transform( $params ); + if ( $thumbnail && !$thumbnail->isError() ) { + return Html::rawElement( 'a', array( + 'href' => $thumbnail->getUrl(), + 'class' => 'mw-thumbnail-link' + ), wfMessage( 'show-big-image-size' )->numParams( + $thumbnail->getWidth(), $thumbnail->getHeight() + )->parse() ); + } else { + return ''; + } + } /** * Show a notice that the file is from a shared repository Modified: trunk/phase3/languages/messages/MessagesEn.php =================================================================== --- trunk/phase3/languages/messages/MessagesEn.php 2011-03-12 22:48:58 UTC (rev 83790) +++ trunk/phase3/languages/messages/MessagesEn.php 2011-03-12 22:49:31 UTC (rev 83791) @@ -3641,7 +3641,9 @@ 'file-nohires' => '<small>No higher resolution available.</small>', 'svg-long-desc' => 'SVG file, nominally $1 × $2 pixels, file size: $3', 'show-big-image' => 'Full resolution', -'show-big-image-thumb' => '<small>Size of this preview: $1 × $2 pixels</small>', +'show-big-image-preview' => '<small> Size of this preview: $1.</small>', +'show-big-image-other' => '<small>Other resolutions: $1.</small>', +'show-big-image-size' => '$1 × $2 pixels', 'file-info-gif-looped' => 'looped', 'file-info-gif-frames' => '$1 {{PLURAL:$1|frame|frames}}', 'file-info-png-looped' => 'looped', Modified: trunk/phase3/maintenance/language/messages.inc =================================================================== --- trunk/phase3/maintenance/language/messages.inc 2011-03-12 22:48:58 UTC (rev 83790) +++ trunk/phase3/maintenance/language/messages.inc 2011-03-12 22:49:31 UTC (rev 83791) @@ -2589,7 +2589,9 @@ 'file-nohires', 'svg-long-desc', 'show-big-image', - 'show-big-image-thumb', + 'show-big-image-preview', + 'show-big-image-other', + 'show-big-image-size', 'file-info-gif-looped', 'file-info-gif-frames', 'file-info-png-looped', _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs