From f8faa940b5cade8fde23343f5468a5d7f59a1e69 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 20 Apr 2007 19:24:53 +0000 Subject: [PATCH] Fixes/tweaks for the image refactoring: * Fix [[Image:Foobar.png]] to use native size instead of thumbnail again * Tweak some parser tests for new order of attributes * Tweak some attributes to match existing tests Down to 9 failing parser tests vs pre-commit state --- includes/Linker.php | 17 +++++++----- maintenance/parserTests.txt | 54 ++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index c34fa211ec..190efebb54 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -451,13 +451,16 @@ class Linker { } if ( !isset( $params['width'] ) ) { - $wopt = $wgUser->getOption( 'thumbsize' ); + $params['width'] = $img->getWidth( $page ); + if( $thumb || $framed ) { + $wopt = $wgUser->getOption( 'thumbsize' ); - if( !isset( $wgThumbLimits[$wopt] ) ) { - $wopt = User::getDefaultOption( 'thumbsize' ); - } + if( !isset( $wgThumbLimits[$wopt] ) ) { + $wopt = User::getDefaultOption( 'thumbsize' ); + } - $params['width'] = min( $img->getWidth( $page ), $wgThumbLimits[$wopt] ); + $params['width'] = min( $params['width'], $wgThumbLimits[$wopt] ); + } } if ( $thumb || $framed ) { @@ -569,8 +572,8 @@ class Linker { ); $linkAttribs = array( 'href' => $u, - 'title' => $alt, - 'class' => 'internal' + 'class' => 'internal', + 'title' => $alt ); $s .= $thumb->toHtml( $imgAttribs, $linkAttribs ); diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 355fb830af..69fbe391ae 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -2946,7 +2946,7 @@ Simple image !! input [[Image:foobar.jpg]] !! result -

Image:foobar.jpg +

Image:foobar.jpg

!! end @@ -2955,7 +2955,7 @@ Right-aligned image !! input [[Image:foobar.jpg|right]] !! result -
+
!! end @@ -2964,7 +2964,7 @@ Image with caption !! input [[Image:foobar.jpg|right|Caption text]] !! result -
Caption text
+
Caption text
!! end @@ -2973,7 +2973,7 @@ Image with frame and link !! input [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]] !! result -
This is a test image Main Page
This is a test image Main Page
+
This is a test image Main Page
This is a test image Main Page
!! end @@ -2993,7 +2993,7 @@ Frameless image caption with a free URL !! input [[Image:foobar.jpg|http://example.com]] !! result -

http://example.com +

http://example.com

!! end @@ -3002,7 +3002,7 @@ Thumbnail image caption with a free URL !! input [[Image:foobar.jpg|thumb|http://example.com]] !! result -
+
!! end @@ -3011,7 +3011,7 @@ BUG 1887: A ISBN with a thumbnail !! input [[Image:foobar.jpg|thumb|ISBN 1235467890]] !! result -
+
!! end @@ -3020,7 +3020,7 @@ BUG 1887: A RFC with a thumbnail !! input [[Image:foobar.jpg|thumb|This is RFC 12354]] !! result -
This is RFC 12354
This is RFC 12354
+
This is RFC 12354
This is RFC 12354
!! end @@ -3029,7 +3029,7 @@ BUG 1887: A mailto link with a thumbnail !! input [[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]] !! result -
+
!! end @@ -3039,7 +3039,7 @@ so math is not stripped and turns up as escaped <math> tags. !! input [[Image:foobar.jpg|thumb|2+2]] !! result -
<math>2+2</math>
<math>2+2</math>
+
<math>2+2</math>
<math>2+2</math>
!! end @@ -3050,7 +3050,7 @@ math !! input [[Image:foobar.jpg|thumb|2+2]] !! result -
2 + 2
2 + 2
+
2 + 2
2 + 2
!! end @@ -3060,7 +3060,7 @@ BUG 648: Frameless image caption with a link !! input [[Image:foobar.jpg|text with a [[link]] in it]] !! result -

text with a link in it +

text with a link in it

!! end @@ -3069,7 +3069,7 @@ BUG 648: Frameless image caption with a link (suffix) !! input [[Image:foobar.jpg|text with a [[link]]foo in it]] !! result -

text with a linkfoo in it +

text with a linkfoo in it

!! end @@ -3078,7 +3078,7 @@ BUG 648: Frameless image caption with an interwiki link !! input [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]] !! result -

text with a MeatBall:Link in it +

text with a MeatBall:Link in it

!! end @@ -3087,7 +3087,7 @@ BUG 648: Frameless image caption with a piped interwiki link !! input [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]] !! result -

text with a link in it +

text with a link in it

!! end @@ -3096,7 +3096,7 @@ Escape HTML special chars in image alt text !! input [[Image:foobar.jpg|& < > "]] !! result -

& < > " +

& < > "

!! end @@ -3105,7 +3105,7 @@ BUG 499: Alt text should have Ӓ, not &1234; !! input [[Image:foobar.jpg|♀]] !! result -

♀ +

♀

!! end @@ -3123,7 +3123,7 @@ Image caption containing another image !! input [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]] !! result -
This is a caption with another Image:Icon.png inside it!
This is a caption with another Image:Icon.png inside it!
+
This is a caption with another Image:Icon.png inside it!
This is a caption with another Image:Icon.png inside it!
!! end @@ -3133,7 +3133,7 @@ Image caption containing a newline [[Image:Foobar.jpg|This *is some text]] !! result -

This *is some text +

This *is some text

!!end @@ -3143,7 +3143,7 @@ Bug 3090: External links other than http: in image captions !! input [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]] !! result -
This caption has irc and Secure ext links in it.
This caption has irc and Secure ext links in it.
+
This caption has irc and Secure ext links in it.
This caption has irc and Secure ext links in it.
!! end @@ -3429,7 +3429,7 @@ BUG 1219 URL next to image (good) !! input http://example.com [[Image:foobar.jpg]] !! result -

http://example.com Image:foobar.jpg +

http://example.com Image:foobar.jpg

!!end @@ -3438,7 +3438,7 @@ BUG 1219 URL next to image (broken) !! input http://example.com[[Image:foobar.jpg]] !! result -

http://example.comImage:foobar.jpg +

http://example.comImage:foobar.jpg

!!end @@ -4713,7 +4713,7 @@ Fuzz testing: image with bogus manual thumbnail !!input [[Image:foobar.jpg|thumbnail= ]] !!result -
+
!!end @@ -5965,7 +5965,7 @@ Centre-aligned image !! input [[Image:foobar.jpg|centre]] !! result -
+
!!end @@ -5974,7 +5974,7 @@ None-aligned image !! input [[Image:foobar.jpg|none]] !! result -
+
!!end @@ -5983,7 +5983,7 @@ Width + Height sized image (using px) (height is ignored) !! input [[Image:foobar.jpg|640x480px]] !! result -

+

!!end @@ -6021,7 +6021,7 @@ Images with the "|" character in the comment !! input [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|¶m2=|x external] URL]] !! result -
An external URL
An external URL
+
An external URL
An external URL
!!end -- 2.20.1