r2461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r2460‎ | r2461 | r2462 >
Date:23:32, 8 February 2004
Author:jeluf
Status:old
Tags:
Comment:
Removed thumb area restriction code, added code to chck for zero-sized thumbnails
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Skin.php
@@ -1527,7 +1527,7 @@
15281528 if ( $wgUseImageMagick ) {
15291529 # use ImageMagick
15301530 $cmd = $wgImageMagickConvertCommand .
1531 - " -quality 95 -geometry {$width} ".
 1531+ " -quality 85 -geometry {$width} ".
15321532 escapeshellarg($imgPath) . " " .
15331533 escapeshellarg($thumbPath);
15341534 $conv = shell_exec( $cmd );
@@ -1585,6 +1585,16 @@
15861586
15871587
15881588 }
 1589+ #
 1590+ # Check for zero-sized thumbnails. Those can be generated when
 1591+ # no disk space is available or some other error occurs
 1592+ #
 1593+ $thumbstat = stat( $thumbPath );
 1594+ $imgstat = stat( $imgPath );
 1595+ if( $thumbstat["size"] == 0 )
 1596+ {
 1597+ unlink( $thumbPath );
 1598+ }
15891599
15901600 }
15911601 return $thumbUrl;
@@ -1601,18 +1611,13 @@
16021612 $label = htmlspecialchars( $label );
16031613
16041614 list($width, $height, $type, $attr) = getimagesize( $path );
1605 - $cwidth = $boxwidth;
1606 - $cheight = intval( $height/($width/$cwidth) );
1607 - if ($cheight > $boxwidth*1.5) {
1608 - $cheight = $boxwidth*1.3;
1609 - $cwidth = intval( $width/($height/$cheight) );
 1615+ $boxheight = intval( $height/($width/$boxwidth) );
 1616+ if ( $boxwidth > $width ) {
 1617+ $boxwidth = $width;
 1618+ $boxheight = $height;
16101619 }
1611 - if ( $cwidth > $width ) {
1612 - $cwidth = $width;
1613 - $cheight = $height;
1614 - }
16151620
1616 - $thumbUrl = $this->createThumb( $name, $cwidth );
 1621+ $thumbUrl = $this->createThumb( $name, $boxwidth );
16171622
16181623 $u = wfLocalUrlE( $link );
16191624
@@ -1620,7 +1625,7 @@
16211626
16221627 $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">" .
16231628 "<a href=\"{$u}\" class=\"internal\" title=\"{$label}\">" .
1624 - "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$label}\" width=\"{$cwidth}\" height=\"{$cheight}\"></a>" .
 1629+ "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$label}\" width=\"{$boxwidth}\" height=\"{$boxheight}\"></a>" .
16251630 "<a href=\"{$u}\" class=\"internal\" title=\"{$more}\">" .
16261631 "<img border=\"0\" src=\"{$wgUploadPath}/magnify-clip.png\" width=\"26\" height=\"24\" align=\"right\" alt=\"{$more}\"></a>" .
16271632 "<p>{$label}</p></div>";

Status & tagging log