From 03a00bb732c0cf8792d4a1316206de11ec2d2b9b Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 12 Mar 2011 22:49:31 +0000 Subject: [PATCH] (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. --- RELEASE-NOTES | 2 ++ includes/ImagePage.php | 41 ++++++++++++++++++++++++++++--- languages/messages/MessagesEn.php | 4 ++- maintenance/language/messages.inc | 4 ++- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 151789d611..c72cd335ce 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -112,6 +112,8 @@ PHP if you have not done so prior to upgrading MediaWiki. * (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 diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 4cd93ee380..cbac9dc5c3 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -360,16 +360,25 @@ class ImagePage extends Article { # 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 @@ EOT } } } + + /** + * 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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 2bb1e4e866..d716570677 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3641,7 +3641,9 @@ By executing it, your system may be compromised.", 'file-nohires' => 'No higher resolution available.', 'svg-long-desc' => 'SVG file, nominally $1 × $2 pixels, file size: $3', 'show-big-image' => 'Full resolution', -'show-big-image-thumb' => 'Size of this preview: $1 × $2 pixels', +'show-big-image-preview' => ' Size of this preview: $1.', +'show-big-image-other' => 'Other resolutions: $1.', +'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', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 5ecf56a58b..73471d89b9 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2589,7 +2589,9 @@ $wgMessageStructure = array( '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', -- 2.20.1