From 6d20e79faf22ba192704e9afb2e1bc4b619d8899 Mon Sep 17 00:00:00 2001 From: Platonides Date: Sat, 7 Aug 2010 22:35:23 +0000 Subject: [PATCH] Make thumbsize option go through ParserOptions. Yet another parameter for makeImageLink2... --- includes/Linker.php | 12 +++++------- includes/parser/Parser.php | 2 +- includes/parser/ParserOptions.php | 3 +++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 35da05d840..7531b88062 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 51ef092aae..29775c6134 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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 ) { diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index c8c13e6b1b..533096c99b 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -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 ); } -- 2.20.1