From 079c3dda80358b0b322b36f041bf1b82bf930069 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Wed, 5 Mar 2014 12:26:28 -0500 Subject: [PATCH] Ignore height as well as width for framed images. This makes the PHP parser behavior consistent with the specification at https://www.mediawiki.org/wiki/Help:Images#Size_and_frame which says: "An image with frame always ignores the size specification." This is actually a fix to File::getUnscaledThumb() -- which didn't actually return an unscaled thumb if the 'height' parameter was set. Bug: 62258 Change-Id: I0ce295a4681042c446314945da5f811448b44fe6 --- includes/filerepo/file/File.php | 2 ++ tests/parser/parserTests.txt | 21 ++++++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index edf574f773..21ff65cd70 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -842,6 +842,8 @@ abstract class File { return $this->iconThumb(); } $hp['width'] = $width; + // be sure to ignore any height specification as well (bug 62258) + unset( $hp['height'] ); return $this->transform( $hp ); } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e8e71b8047..d958f92c46 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10172,8 +10172,7 @@ parsoid=wt2html,wt2wt,html2html # Foobar has actual size of 1941x220 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's # a scalable format. -# 2. Framed images ignore width; always render at default size. -# If given a height, they respect height but continue to ignore width. +# 2. Framed images always ignore size options; always render at default size. # 3. "Unspecified format" and border are the only types which can be # enlarged. @@ -10272,7 +10271,7 @@ parsoid=wt2html,wt2wt,html2html !! end !! test -Image: framed images ignore size if only width is given +Image: framed images are always unscaled. !! options parsoid=wt2html,wt2wt,html2html !! wikitext @@ -10280,25 +10279,17 @@ parsoid=wt2html,wt2wt,html2html [[File:Foobar.jpg|frame|50px]] +[[File:Foobar.jpg|frame|50x50px]] + [[File:Foobar.jpg|frame|2000px]] !! html/php
Foobar.jpg
Foobar.jpg
Foobar.jpg
+
Foobar.jpg
!! html/parsoid -
-!! end - -!! test -Image: framed images respect size if given a height, but ignore width. -!! wikitext -[[File:Foobar.jpg|frame|50x50px]] -!! html/php -
Foobar.jpg
- -!! html/parsoid -
+
!! end ################### -- 2.20.1