Fix 8335 : Image syntax does not parse "px" in image caption correctly
authorAntoine Musso <hashar@users.mediawiki.org>
Wed, 20 Dec 2006 14:24:57 +0000 (14:24 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Wed, 20 Dec 2006 14:24:57 +0000 (14:24 +0000)
RELEASE-NOTES
includes/Parser.php

index ba81800..b52c3f8 100644 (file)
@@ -363,6 +363,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   automatically logs the user in with the new password after changing
   it; pulling from slave meant the record was often not the updated
   one.
+* (bug 8335) Set image width to the first valid parameter found.
 
 == Languages updated ==
 
index 97a1f13..1642105 100644 (file)
@@ -4407,15 +4407,15 @@ class Parser
                                   && ! is_null( $match = $mwPage->matchVariableStartToEnd($val) ) ) {
                                # Select a page in a multipage document
                                $page = $match;
-                       } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
+                       } elseif ( $wgUseImageResize && !$width && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
                                wfDebug( "img_width match: $match\n" );
                                # $match is the image width in pixels
                                $m = array();
-                               if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
+                               if ( is_numeric($match) ) {
+                                       $width = intval($match);
+                               } elseif ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
                                        $width = intval( $m[1] );
                                        $height = intval( $m[2] );
-                               } else {
-                                       $width = intval($match);
                                }
                        } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
                                $framed=true;