-$img = Image::newFromName( $fileName );
-if ( $img ) {
- if ( ! is_null( $page ) ) {
- $img->selectPage( $page );
+ $errorMsg = false;
+ if ( !$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 {
+ wfStreamFile( $thumb->getPath() );
+ }
+ if ( $errorMsg !== false ) {
+ wfThumbError( 500, $errorMsg );