From 7db55341791cb44ca599b84bea707b05de2f227d Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 25 Mar 2014 12:48:55 -0400 Subject: [PATCH] Use square bounding boxes for default-sized thumbnails Thumbnails for portrait-orientation images have always been "too big", especially when displayed in a gallery. The 'upright' option did not completely fix the issue. Using a square bounding box for thumbnails (and 'framed' images) without an explicit size specifiction provides a better default appearance. This also provides a clean syntax for content authored using Parsoid/Visual Editor, which prefers square bounding boxes. See: https://www.mediawiki.org/wiki/Requests_for_comment/Square_bounding_boxes Bug: 63903 Change-Id: I665d8945843d3b5437a74e376b63c44965590116 --- RELEASE-NOTES-1.24 | 3 + includes/Linker.php | 10 ++- tests/parser/parserTest.inc | 54 +++++++++++++++++ tests/parser/parserTests.txt | 57 +++++++++++++++++- tests/phpunit/data/media/Portrait.png | Bin 0 -> 7189 bytes .../phpunit/includes/parser/NewParserTest.php | 52 ++++++++++++++++ 6 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/data/media/Portrait.png diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 439420bc9c..f067e32b39 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -38,6 +38,9 @@ production. * WikitextContent will now render redirects with the expected "redirect" header, rather than as an ordered list. Code calling Article::viewRedirect can probably be changed to no longer special-case redirects. +* (bug 63903) Thumbnails without an explicit size specification are + now resized to a square bounding box. This gives better results for + non-landscape thumbnails. === Bug fixes in 1.24 === * (bug 49116) Footer copyright notice is now always displayed in user language diff --git a/includes/Linker.php b/includes/Linker.php index d0759edd96..7724548628 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -603,6 +603,7 @@ class Linker { } // Reduce width for upright images when parameter 'upright' is used + $useSquare = !isset( $fp['upright'] ); if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) { $fp['upright'] = $wgThumbUpright; } @@ -614,11 +615,16 @@ class Linker { round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) : $wgThumbLimits[$widthOption]; - // Use width which is smaller: real image width or user preference width + // Use whichever is smaller: real image width or user preference width // Unless image is scalable vector. if ( !isset( $hp['height'] ) && ( $hp['width'] <= 0 || - $prefWidth < $hp['width'] || $file->isVectorized() ) ) { + $prefWidth < $hp['width'] || + ( $useSquare && $prefWidth < $file->getHeight( $page ) ) || + $file->isVectorized() ) ) { $hp['width'] = $prefWidth; + if ( $useSquare ) { + $hp['height'] = $prefWidth; + } } } } diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 1875ac5cca..0bbee17535 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -1015,6 +1015,34 @@ class ParserTest { 'fileExists' => true ), $this->db->timestamp( '20010115123500' ), $user ); + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Portrait.png' ) ); + # again, note that size/width/height below are ignored; see above. + $image->recordUpload2( '', 'Upload of tall bitmap', 'Some tall bitmap', array( + 'size' => 12345, + 'width' => 180, + 'height' => 240, + 'bits' => 8, + 'media_type' => MEDIATYPE_BITMAP, + 'mime' => 'image/png', + 'metadata' => serialize( array() ), + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'fileExists' => true + ), $this->db->timestamp( '20140515134200' ), $user ); + + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Portrait.svg' ) ); + # again, note that size/width/height below are ignored; see above. + $image->recordUpload2( '', 'Upload of tall SVG', 'Some tall SVG', array( + 'size' => 12345, + 'width' => 180, + 'height' => 240, + 'bits' => 24, + 'media_type' => MEDIATYPE_DRAWING, + 'mime' => 'image/svg+xml', + 'metadata' => serialize( array() ), + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'fileExists' => true + ), $this->db->timestamp( '20140325124200' ), $user ); + # This image will be blacklisted in [[MediaWiki:Bad image list]] $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) ); $image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array( @@ -1144,6 +1172,13 @@ class ParserTest { '' . '' ); + wfMkdirParents( $dir . '/9/93', null, __METHOD__ ); + copy( "$IP/tests/phpunit/data/media/Portrait.png", "$dir/9/93/Portrait.png" ); + wfMkdirParents( $dir . '/f/fc', null, __METHOD__ ); + file_put_contents( "$dir/f/fc/Portrait.svg", + '' . + '' ); wfMkdirParents( $dir . '/5/5f', null, __METHOD__ ); copy( "$IP/tests/phpunit/data/media/LoremIpsum.djvu", "$dir/5/5f/LoremIpsum.djvu" ); @@ -1230,6 +1265,17 @@ class ParserTest { "$dir/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png", "$dir/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png", + "$dir/9/93/Portrait.png", + "$dir/thumb/9/93/Portrait.png/165px-Portrait.png", + + "$dir/f/fc/Portrait.svg", + "$dir/thumb/f/fc/Portrait.svg/165px-Portrait.svg.png", + "$dir/thumb/f/fc/Portrait.svg/225px-Portrait.svg.png", + "$dir/thumb/f/fc/Portrait.svg/247px-Portrait.svg.png", + "$dir/thumb/f/fc/Portrait.svg/330px-Portrait.svg.png", + "$dir/thumb/f/fc/Portrait.svg/337px-Portrait.svg.png", + "$dir/thumb/f/fc/Portrait.svg/450px-Portrait.svg.png", + "$dir/math/f/a/5/fa50b8b616463173474302ca3e63586b.png", ) ); @@ -1241,10 +1287,18 @@ class ParserTest { "$dir/thumb/3/3a/Foobar.jpg", "$dir/thumb/3/3a", "$dir/thumb/3", + "$dir/9/93", + "$dir/9", + "$dir/thumb/9/93/Portrait.png", + "$dir/thumb/9/93/", + "$dir/thumb/9/", "$dir/e/ea", "$dir/e", + "$dir/f/fc/", "$dir/f/ff/", "$dir/f/", + "$dir/thumb/f/fc/Portrait.svg", + "$dir/thumb/f/fc/", "$dir/thumb/f/ff/Foobar.svg", "$dir/thumb/f/ff/", "$dir/thumb/f/", diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 569c165321..55801aadfa 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -7755,7 +7755,7 @@ Magic Word: {{NUMBEROFFILES}} !! wikitext {{NUMBEROFFILES}} !! html -

5 +

7

!! end @@ -10793,12 +10793,16 @@ parsoid=wt2html,wt2wt,html2html # Image sizing. # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame # and https://bugzilla.wikimedia.org/show_bug.cgi?id=62258 -# Foobar has actual size of 1941x220 +# Foobar.jpg has actual size of 1941x220 +# Portrait.svg has actual size of 180x240 +# Portrait.png has actual size of 180x240 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's # a scalable format. # 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. +# 4. Without an explicit size specification, thumbnails are +# resized to a square bounding box. !! test Image: "unspecified format" and border enlarge @@ -10916,6 +10920,55 @@ parsoid=wt2html,wt2wt,html2html
!! end +!! test +Image: thumbnails of the default size use a square bounding box. +!! options +thumbsize=220 +!! wikitext +[[File:Foobar.jpg|thumb|landscape thumb]] + +[[File:Foobar.jpg|frameless|landscape frameless]] + +[[File:Portrait.png|thumb|should use 220x220px bounding box]] + +[[File:Portrait.png|frameless|should use 220x220px bounding box]] + +[[File:Portrait.svg|thumb|should use 220x220px bounding box]] + +[[File:Portrait.svg|frameless|should use 220x220px bounding box]] +!! html/php +
landscape thumb
+

landscape frameless +

+
should use 220x220px bounding box
+

should use 220x220px bounding box +

+
should use 220x220px bounding box
+

should use 220x220px bounding box +

+!! end + +!! test +Image: bitmap thumbnails reduce only if thumb size is smaller than inherent size. +!! options +thumbsize=300 +!! wikitext +[[File:Portrait.png|thumb|should use inherent 180x240px size]] + +[[File:Portrait.png|frameless|should use inherent 180x240px size]] + +[[File:Portrait.svg|thumb|will resize to 300x300px]] + +[[File:Portrait.svg|frameless|will resize to 300x300px]] +!! html/php +
should use inherent 180x240px size
+

should use inherent 180x240px size +

+
will resize to 300x300px
+

will resize to 300x300px +

+!! end + ################### !! test diff --git a/tests/phpunit/data/media/Portrait.png b/tests/phpunit/data/media/Portrait.png new file mode 100644 index 0000000000000000000000000000000000000000..b5a92f6c0dde0ec2c61d234b46eec7091a7c45da GIT binary patch literal 7189 zcmb7pWmJ?=)GjF{L-$C7Ac%s*fOJTANQb0^3=AMccT0=p3?Lw)v~&)jq=bMYj=<0{ z)X>d0U##!Xz4ym`*E;W6?^*kt{jO*4bM~{(PBhR{rzB@3$HT*;)YMQl!u8*9?SPa3 z_vUw*g;h;J@bK7rHC2^N0{`w7p@ROpHO3H= zYAU+y-92)JftbG${#JUt&~upKRF^>%w@0X;x6G^j$n>Rm_ukx=-$-9ynDbF9u>*c; z9iF;*1dnhp4I`SA0vtmO>LURD&+z|i{J+Kj5BWciR_rZk)+4&_jdQs5P8H0p*`>mX z6J&`%se>zb*Z)Fp-ReL^dSS7RbDoj~TQYDq?hBsYKJS}o#Z|xN73>gldW+Y5%;njg ze6J{@FmBQk7;GMqa;2=A3jzY-`%CtNZR+sq&4mwTnZyWy{XB%`2Y7m)veFUNJxucG zl>Vhje;cGf!5}uU@TUtDwgC;3Df&-Y_CW@DDhL>ZY9TGdyEe|fs-I*iRXD!FPetr?q#Gjrr^Ta&uz~cTq*9!6XN&O-NLTTh5gUQ}w0OIQ z=%8<#AJfsm_?r9}m%^`RFPvVR{eX_{eX96=Pf4Mq(yB)bqoo4Yu{t`Qp^FrVtD9~w zE3{Dd(9L5;il`5GgZAz!eqE?tKTJnW7J9RNd~tLO!R3}D&6(Ehb=3`@*ce@-U7I@V zI>2Vba7uh+id5NckP^C$i~DaoigH!A+5(*DN^by4ed}6$}!+gSw6t8Dz-Dl6b z*e3=$A9K>S;ml^kX1N+Do1~35eIz>gKwL7{T;#*(no%O9(bSM4G$<5)Q*|t{%|QEg zJA?2a&eS^TvwYI0A!9xyU{V(J$Ersqs%6U#1gS58^5sZKDfb)Y${=!vpEPLZomrDi z#VX_T^y_2cgnym1_vdQ2As^jSzt5#}YCafODX>pP=ty-5k2VN@7HoVt4wl6@>9FU-ln_wVi#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zmu}0o@)a*~#Y>$WN}78k^xB#sQC7VhwL9}l#E3?$sxkEH)T_xdL##(Td0J(oAT*oX zyOGpPQ0;Os*9H*>{r=p5afJTLR*P4>FUGmX+x0ip!&#qLDOimlCyJ~SS;-hPq^ zF|l4;#%Y9Xc0ZoL+(Z`J94y}4L4;gvdMy_Aje>%-zvaQB@O@$@Q4%_+A2g{k#zy&f zgRoQq<&gdPR99wOW34|kk@H}l(#dB?0OEuMlLBChqu1zOdUGIaZST_jV1Y2FY-S^P z^+M{q75V2FOSS6NXGF<8cehqX^bdjt#qXHD_yqeJKXw`cr|*KD^K}AsB^|C{T5sio z3b<(FV>fzOgqAI+2Pw64E`%;aIjlsSNXZG}{q99#LMap*YlBn9?1I=8CQx@nY@LDNwXx#R!f7O4PaQkEBiK4#CvkJPHHpr4xSCubIA8(Uf z1H4~kiVU2RkUPNF7Q#gtE=I^02<+w`rWLD#N%5TAf)k_h22T#x-i8xdccx~AbbTF` zyDcuo8%$^4&aa(YIYE$s`s6+Tf6Hm?Bezt1jK#?Ki|BD&oexh_O;5E(**@w&07A<1 Ar~m)} literal 0 HcmV?d00001 diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 14bcac097a..26efa4a54f 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -285,6 +285,34 @@ class NewParserTest extends MediaWikiTestCase { 'fileExists' => true ), $this->db->timestamp( '20010115123500' ), $user ); } + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Portrait.png' ) ); + if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { + $image->recordUpload2( '', 'Upload of tall bitmap', 'Some tall bitmap', array( + 'size' => 12345, + 'width' => 180, + 'height' => 240, + 'bits' => 8, + 'media_type' => MEDIATYPE_BITMAP, + 'mime' => 'image/png', + 'metadata' => serialize( array() ), + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'fileExists' => true + ), $this->db->timestamp( '20140515134200' ), $user ); + } + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Portrait.svg' ) ); + if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { + $image->recordUpload2( '', 'Upload of tall SVG', 'Some tall SVG', array( + 'size' => 12345, + 'width' => 180, + 'height' => 240, + 'bits' => 24, + 'media_type' => MEDIATYPE_DRAWING, + 'mime' => 'image/svg+xml', + 'metadata' => serialize( array() ), + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'fileExists' => true + ), $this->db->timestamp( '20140325124200' ), $user ); + } # A DjVu file $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) ); @@ -499,6 +527,10 @@ class NewParserTest extends MediaWikiTestCase { $backend->store( array( 'src' => "$IP/skins/monobook/headbg.jpg", 'dst' => "$base/local-public/0/09/Bad.jpg" ) ); + $backend->prepare( array( 'dir' => "$base/local-public/9/93" ) ); + $backend->store( array( + 'src' => "$IP/tests/phpunit/data/media/Portrait.png", 'dst' => "$base/local-public/9/93/Portrait.png" + ) ); $backend->prepare( array( 'dir' => "$base/local-public/5/5f" ) ); $backend->store( array( 'src' => "$IP/tests/phpunit/data/media/LoremIpsum.djvu", 'dst' => "$base/local-public/5/5f/LoremIpsum.djvu" @@ -513,6 +545,15 @@ class NewParserTest extends MediaWikiTestCase { $backend->quickCreate( array( 'content' => $data, 'dst' => "$base/local-public/f/ff/Foobar.svg" ) ); + + $data = '' . + ''; + + $backend->prepare( array( 'dir' => "$base/local-public/f/fc" ) ); + $backend->quickCreate( array( + 'content' => $data, 'dst' => "$base/local-public/f/fc/Portrait.svg" + ) ); } /** @@ -587,6 +628,9 @@ class NewParserTest extends MediaWikiTestCase { "$base/local-thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg", "$base/local-thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg", + "$base/local-public/9/93/Portrait.png", + "$base/local-thumb/9/93/Portrait.png/165px-Portrait.png", + "$base/local-public/f/ff/Foobar.svg", "$base/local-thumb/f/ff/Foobar.svg/180px-Foobar.svg.png", "$base/local-thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png", @@ -598,6 +642,14 @@ class NewParserTest extends MediaWikiTestCase { "$base/local-thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png", "$base/local-thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png", + "$base/local-public/f/fc/Portrait.svg", + "$base/local-thumb/f/fc/Portrait.svg/165px-Portrait.svg.png", + "$base/local-thumb/f/fc/Portrait.svg/225px-Portrait.svg.png", + "$base/local-thumb/f/fc/Portrait.svg/247px-Portrait.svg.png", + "$base/local-thumb/f/fc/Portrait.svg/330px-Portrait.svg.png", + "$base/local-thumb/f/fc/Portrait.svg/337px-Portrait.svg.png", + "$base/local-thumb/f/fc/Portrait.svg/450px-Portrait.svg.png", + "$base/local-public/math/f/a/5/fa50b8b616463173474302ca3e63586b.png", ) ); -- 2.20.1