From: Tim Starling Date: Mon, 3 Sep 2007 21:35:27 +0000 (+0000) Subject: Return an error message if the requested size was bigger than the source, or more... X-Git-Tag: 1.31.0-rc.0~51533 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=a910a32f760c38b99d5be658a36679e62a610724;p=lhc%2Fweb%2Fwiklou.git Return an error message if the requested size was bigger than the source, or more generally if the "transformed" output file is in fact the source file. --- diff --git a/thumb.php b/thumb.php index 2159d2ee65..dbc07c2150 100644 --- a/thumb.php +++ b/thumb.php @@ -69,21 +69,23 @@ try { $thumb = false; } -if ( $thumb && $thumb->getPath() && file_exists( $thumb->getPath() ) ) { - wfStreamFile( $thumb->getPath() ); +$errorMsg = false; +if ( !$img ) { + $errorMsg = wfMsg( 'badtitletext' ); +} elseif ( !$thumb ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' ); +} elseif ( $thumb->isError() ) { + $errorMsg = $thumb->getHtmlMsg(); +} elseif ( !$thumb->getPath() ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); +} elseif ( $thumb->getPath() == $img->getPath() ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'Image was not scaled, ' . + 'is the requested width bigger than the source?' ); } else { - if ( !$img ) { - $msg = wfMsg( 'badtitletext' ); - } elseif ( !$thumb ) { - $msg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' ); - } elseif ( $thumb->isError() ) { - $msg = $thumb->getHtmlMsg(); - } elseif ( !$thumb->getPath() ) { - $msg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); - } else { - $msg = wfMsgHtml( 'thumbnail_error', 'Output file missing' ); - } - thumbInternalError( $msg ); + wfStreamFile( $thumb->getPath() ); +} +if ( $errorMsg !== false ) { + thumbInternalError( $errorMsg ); } wfProfileOut( 'thumb.php-render' );