Make thumbsize option go through ParserOptions.
authorPlatonides <platonides@users.mediawiki.org>
Sat, 7 Aug 2010 22:35:23 +0000 (22:35 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sat, 7 Aug 2010 22:35:23 +0000 (22:35 +0000)
Yet another parameter for makeImageLink2...

includes/Linker.php
includes/parser/Parser.php
includes/parser/ParserOptions.php

index 35da05d..7531b88 100644 (file)
@@ -433,7 +433,7 @@ class Linker {
         * @param $query String: query params for desc url
         * @return String: HTML for an image, with links, wrappers, etc.
         */
-       function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "" ) {
+       function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
                $res = null;
                if( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title,
                &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
@@ -467,10 +467,8 @@ class Linker {
                        $hp['width'] = $file->getWidth( $page );
 
                        if( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
-                               $wopt = $wgUser->getOption( 'thumbsize' );
-
-                               if( !isset( $wgThumbLimits[$wopt] ) ) {
-                                        $wopt = User::getDefaultOption( 'thumbsize' );
+                               if( !isset( $widthOption ) || !isset( $wgThumbLimits[$widthOption] ) ) {
+                                        $widthOption = User::getDefaultOption( 'thumbsize' );
                                }
 
                                // Reduce width for upright images when parameter 'upright' is used
@@ -480,8 +478,8 @@ class Linker {
                                // Use width which is smaller: real image width or user preference width
                                // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
                                $prefWidth = isset( $fp['upright'] ) ?
-                                       round( $wgThumbLimits[$wopt] * $fp['upright'], -1 ) :
-                                       $wgThumbLimits[$wopt];
+                                       round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
+                                       $wgThumbLimits[$widthOption];
                                if ( $hp['width'] <= 0 || $prefWidth < $hp['width'] ) {
                                        if( !isset( $hp['height'] ) ) {
                                                $hp['width'] = $prefWidth;
index 51ef092..29775c6 100644 (file)
@@ -4777,7 +4777,7 @@ class Parser {
                wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
 
                # Linker does the rest
-               $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery );
+               $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery, $this->mOptions->getThumbSize() );
 
                # Give the handler a chance to modify the parser object
                if ( $handler ) {
index c8c13e6..533096c 100644 (file)
@@ -31,6 +31,7 @@ class ParserOptions {
        var $mExternalLinkTarget;        # Target attribute for external links
        var $mMath;                      # User math preference (as integer)
        var $mUserLang;                  # Language code of the User language.
+       var $mThumbSize;                 # Thumb size preferred by the user.
 
        var $mUser;                      # Stored user object, just used to initialise the skin
        var $mIsPreview;                 # Parsing the page for a "preview" operation
@@ -58,6 +59,7 @@ class ParserOptions {
        function getCleanSignatures()               { return $this->mCleanSignatures; }
        function getExternalLinkTarget()            { return $this->mExternalLinkTarget; }
        function getMath()                          { return $this->mMath; }
+       function getThumbSize()                     { return $this->mThumbSize; }
        
        function getIsPreview()                     { return $this->mIsPreview; }
        function getIsSectionPreview()              { return $this->mIsSectionPreview; }
@@ -115,6 +117,7 @@ class ParserOptions {
        function setExternalLinkTarget( $x )        { return wfSetVar( $this->mExternalLinkTarget, $x ); }
        function setMath( $x )                      { return wfSetVar( $this->mMath, $x ); }
        function setUserLang( $x )                  { return wfSetVar( $this->mUserLang, $x ); }
+       function setThumbSize()                     { return wfSetVar( $this->mThumbSize, $x ); }
        
        function setIsPreview( $x )                 { return wfSetVar( $this->mIsPreview, $x ); }
        function setIsSectionPreview( $x )          { return wfSetVar( $this->mIsSectionPreview, $x ); }