From: Raimond Spekking Date: Mon, 28 May 2007 19:15:43 +0000 (+0000) Subject: After revert of r22435 and talk with Brion on IRC previously introduced and newly... X-Git-Tag: 1.31.0-rc.0~52781 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=9496f7f3ac4e7582d6b23a536b925b1782e87020;p=lhc%2Fweb%2Fwiklou.git After revert of r22435 and talk with Brion on IRC previously introduced and newly function parameters merged to an array. Introducing 'frameless' keyword to [[Image:]] syntax which respects the user preferences for image width like 'thumb' but without a frame. Now we can use frameless images without the need to nailing its size by a constant pixel parameter. Scaling by different user preference/anon view will always keep the proportions. Usage: [[Image:name.jpg|frameless|right]] --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4b577a3b35..2bbdb87513 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -34,13 +34,15 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 9628) Show warnings about slave lag on Special:Contributions, Special:Watchlist * (bug 8818) Expose "wpDestFile" as parameter $1 to "uploaddisabledtext" -* Introducing new image parameter 'upright' and corresponding variable +* Introducing new image keyword 'upright' and corresponding variable $wgThumbUpright. This allows better proportional view of upright images related to landscape images on a page without nailing the width of upright images to a fix value which makes views for anon unproportional and user preferences useless -* (bug 6072) Add a 'border' keyword to the image syntax - +* (bug 6072) Introducing 'border' keyword to the [[Image:]] syntax +* Introducing 'frameless' keyword to [[Image:]] syntax which respects the + user preferences for image width like 'thumb' but without a frame. + == Bugfixes since 1.10 == * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi diff --git a/includes/Linker.php b/includes/Linker.php index 1cb40db1e4..326b3bc12c 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -427,9 +427,20 @@ class Linker { return $s; } - /** @todo document */ + /** Creates the HTML source for images + * @param object $nt + * @param string $label label text + * @param string $alt alt text + * @param string $align horizontal alignment: none, left, center, right) + * @param array $params some format keywords: width, height, page, upright, upright_factor, frameless, border + * @param boolean $framed shows image in original size in a frame + * @param boolean $thumb shows image as thumbnail in a frame + * @param string $manual_thumb image name for the manual thumbnail + * @param string $valign vertical alignment: baseline, sub, super, top, text-top, middle, bottom, text-bottom + * @return string + */ function makeImageLinkObj( $nt, $label, $alt, $align = '', $params = array(), $framed = false, - $thumb = false, $manual_thumb = '', $valign = '', $upright = false, $upright_factor = 0, $border = false ) + $thumb = false, $manual_thumb = '', $valign = '' ) { global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright; @@ -448,10 +459,9 @@ class Linker { $postfix = ''; $align = 'none'; } - if ( !isset( $params['width'] ) ) { $params['width'] = $img->getWidth( $page ); - if( $thumb || $framed ) { + if( $thumb || $framed || isset( $params['frameless'] ) ) { $wopt = $wgUser->getOption( 'thumbsize' ); if( !isset( $wgThumbLimits[$wopt] ) ) { @@ -459,12 +469,12 @@ class Linker { } // Reduce width for upright images when parameter 'upright' is used - if ( $upright_factor == 0 ) { - $upright_factor = $wgThumbUpright; + if ( !isset( $params['upright_factor'] ) || $params['upright_factor'] == 0 ) { + $params['upright_factor'] = $wgThumbUpright; } // 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 - $params['width'] = min( $params['width'], $upright ? round( $wgThumbLimits[$wopt] * $upright_factor, -1 ) : $wgThumbLimits[$wopt] ); + $params['width'] = min( $params['width'], isset( $params['upright'] ) ? round( $wgThumbLimits[$wopt] * $params['upright_factor'], -1 ) : $wgThumbLimits[$wopt] ); } } @@ -480,7 +490,7 @@ class Linker { if ( $align == '' ) { $align = $wgContLang->isRTL() ? 'left' : 'right'; } - return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb, $upright ).$postfix; + return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb ).$postfix; } if ( $params['width'] && $img->exists() ) { @@ -504,7 +514,7 @@ class Linker { if ( $valign ) { $imgAttribs['style'] = "vertical-align: $valign"; } - if ( $border ) { + if ( isset( $params['border'] ) ) { $imgAttribs['class'] = "thumbborder"; } $linkAttribs = array( @@ -528,14 +538,14 @@ class Linker { * Make HTML for a thumbnail including image, border and caption * $img is an Image object */ - function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "", $upright = false ) { + function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "" ) { global $wgStylePath, $wgContLang; $page = isset( $params['page'] ) ? $params['page'] : false; if ( empty( $params['width'] ) ) { // Reduce width for upright images when parameter 'upright' is used - $params['width'] = $upright ? 130 : 180; + $params['width'] = isset( $params['upright'] ) ? 130 : 180; } $thumb = false; if ( $manual_thumb != '' ) { diff --git a/includes/Parser.php b/includes/Parser.php index 9567d335c0..a570423952 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -4418,6 +4418,7 @@ class Parser # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox # * center center the image # * framed Keep original image size, no magnify-button. + # * frameless like 'thumb' but without a frame. Keeps user preferences for width # * upright reduce width for upright images, rounded to full __0 px # * border draw a 1px border around the image # vertical-align values (no % or length right now): @@ -4442,6 +4443,7 @@ class Parser $mwManualThumb =& MagicWord::get( 'img_manualthumb' ); $mwWidth =& MagicWord::get( 'img_width' ); $mwFramed =& MagicWord::get( 'img_framed' ); + $mwFrameless =& MagicWord::get( 'img_frameless' ); $mwUpright =& MagicWord::get( 'img_upright' ); $mwBorder =& MagicWord::get( 'img_border' ); $mwPage =& MagicWord::get( 'img_page' ); @@ -4449,9 +4451,6 @@ class Parser $params = array(); $framed = $thumb = false; - $upright = false; - $upright_factor = 0; - $border = false; $manual_thumb = '' ; $align = $valign = ''; $sk = $this->mOptions->getSkin(); @@ -4460,10 +4459,12 @@ class Parser if ( !is_null( $mwThumb->matchVariableStartToEnd($val) ) ) { $thumb=true; } elseif ( !is_null( $match = $mwUpright->matchVariableStartToEnd( $val ) ) ) { - $upright = true; - $upright_factor = floatval( $match ); + $params['upright'] = true; + $params['upright_factor'] = floatval( $match ); + } elseif ( !is_null( $match = $mwFrameless->matchVariableStartToEnd( $val ) ) ) { + $params['frameless'] = true; } elseif ( !is_null( $mwBorder->matchVariableStartToEnd( $val ) ) ) { - $border = true; + $params['border'] = true; } elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) { # use manually specified thumbnail $thumb=true; @@ -4510,7 +4511,7 @@ class Parser $alt = Sanitizer::stripAllTags( $alt ); # Linker does the rest - return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign, $upright, $upright_factor, $border ); + return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign ); } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index fa5edfe074..1e52559e84 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -281,6 +281,7 @@ $magicWords = array( 'img_width' => array( 1, '$1px' ), 'img_center' => array( 1, 'center', 'centre' ), 'img_framed' => array( 1, 'framed', 'enframed', 'frame' ), + 'img_frameless' => array( 1, 'frameless' ), 'img_page' => array( 1, 'page=$1', 'page $1' ), 'img_upright' => array( 1, 'upright', 'upright=$1', 'upright $1' ), 'img_border' => array( 1, 'border' ),