(bug 2581, bug 6834) Added links to thumbnail in several resolutions to the file...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 12 Mar 2011 22:49:31 +0000 (22:49 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 12 Mar 2011 22:49:31 +0000 (22:49 +0000)
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
includes/ImagePage.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 151789d..c72cd33 100644 (file)
@@ -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
index 4cd93ee..cbac9dc 100644 (file)
@@ -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
index 2bb1e4e..d716570 100644 (file)
@@ -3641,7 +3641,9 @@ By executing it, your system may be compromised.",
 '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',
index 5ecf56a..73471d8 100644 (file)
@@ -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',