r75749 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75748‎ | r75749 | r75750 >
Date:21:53, 31 October 2010
Author:hartman
Status:resolved (Comments)
Tags:
Comment:
Upscale thumbnails of SVGs if the nominal size of the SVG is smaller than the thumbnail size.

Fixes bug 19633. Requires r75748
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -433,6 +433,7 @@
434434 * to transform(). Typical keys are "width" and "page".
435435 * @param $time String: timestamp of the file, set as false for current
436436 * @param $query String: query params for desc url
 437+ * @param $widthOption: Used by the parser to remember the user preference thumbnailsize
437438 * @return String: HTML for an image, with links, wrappers, etc.
438439 */
439440 function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
@@ -442,7 +443,6 @@
443444 return $res;
444445 }
445446
446 - global $wgContLang, $wgThumbLimits, $wgThumbUpright;
447447 if ( $file && !$file->allowInlineDisplay() ) {
448448 wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" );
449449 return $this->link( $title );
@@ -469,28 +469,31 @@
470470 $hp['width'] = $file->getWidth( $page );
471471
472472 if ( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
 473+ global $wgThumbLimits, $wgThumbUpright;
473474 if ( !isset( $widthOption ) || !isset( $wgThumbLimits[$widthOption] ) ) {
474 - $widthOption = User::getDefaultOption( 'thumbsize' );
 475+ $widthOption = User::getDefaultOption( 'thumbsize' );
475476 }
476477
477478 // Reduce width for upright images when parameter 'upright' is used
478479 if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
479480 $fp['upright'] = $wgThumbUpright;
480481 }
481 - // Use width which is smaller: real image width or user preference width
482482 // 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
483483 $prefWidth = isset( $fp['upright'] ) ?
484484 round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
485485 $wgThumbLimits[$widthOption];
486 - if ( $hp['width'] <= 0 || $prefWidth < $hp['width'] ) {
487 - if ( !isset( $hp['height'] ) ) {
488 - $hp['width'] = $prefWidth;
489 - }
 486+
 487+ // Use width which is smaller: real image width or user preference width
 488+ // Unless image is scalable vector.
 489+ if ( !isset( $hp['height'] ) && ( $hp['width'] <= 0 ||
 490+ $prefWidth < $hp['width'] || $file->isVectorized() ) ) {
 491+ $hp['width'] = $prefWidth;
490492 }
491493 }
492494 }
493495
494 - if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) ) {
 496+ if ( $file && ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) ) ) {
 497+ global $wgContLang;
495498 # Create a thumbnail. Alignment depends on language
496499 # writing direction, # right aligned for left-to-right-
497500 # languages ("Western languages"), left-aligned
@@ -513,7 +516,7 @@
514517 }
515518 }
516519
517 - if ( $file && $hp['width'] ) {
 520+ if ( $file && isset( $hp['width'] ) ) {
518521 # Create a resized image, without the additional thumbnail features
519522 $thumb = $file->transform( $hp );
520523 } else {
Index: trunk/phase3/RELEASE-NOTES
@@ -379,6 +379,7 @@
380380 * (bug 23731) Clarified "n links" message on Special:MostLinkedTemplates
381381 * (bug 25642) A exception is now thrown instead of a fatal error when using
382382 $wgSMTP without PEAR mail package
 383+* (bug 19633) When possible, Upscale small SVGs when creating thumbnails.
383384
384385 === API changes in 1.17 ===
385386 * (bug 22738) Allow filtering by action type on query=logevent.

Follow-up revisions

RevisionCommit summaryAuthorDate
r75819Follow up r75749. Fixes a case with a linked thumbnail of a non-existant image....hartman19:36, 1 November 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75748Add a new isVectorized() to files and media handlers. Only SVG returns true....hartman21:49, 31 October 2010

Comments

#Comment by OverlordQ (talk | contribs)   19:19, 1 November 2010

Running test Template with thumb image (with link in description)... FAILED!
--- /tmp/mwParser-177264444-expected    2010-11-01 19:17:29.000000000 +0000
+++ /tmp/mwParser-177264444-actual      2010-11-01 19:17:29.000000000 +0000
@@ -1,2 +1,2 @@
-This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>  <div class="thumbcaption"><a href="https://www.mediawiki.org/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="https://www.mediawiki.org/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
-
+<p>This is a test template with parameter <a href="https://www.mediawiki.org/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
+</p>

Status & tagging log