MediaWiki  REL1_23
MockImageHandler.php
Go to the documentation of this file.
00001 <?php
00031 class MockImageHandler {
00032 
00039     static function doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
00040         # Example of what we receive:
00041         # $image: LocalFile
00042         # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg
00043         # $dstUrl : http://example.com/images/thumb/0/09/Bad.jpg/320px-Bad.jpg
00044         # $params:  width: 320,  descriptionUrl http://trunk.dev/wiki/File:Bad.jpg
00045 
00046         $that->normaliseParams( $image, $params );
00047 
00048         $scalerParams = array(
00049             # The size to which the image will be resized
00050             'physicalWidth' => $params['physicalWidth'],
00051             'physicalHeight' => $params['physicalHeight'],
00052             'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}",
00053             # The size of the image on the page
00054             'clientWidth' => $params['width'],
00055             'clientHeight' => $params['height'],
00056             # Comment as will be added to the EXIF of the thumbnail
00057             'comment' => isset( $params['descriptionUrl'] ) ?
00058                     "File source: {$params['descriptionUrl']}" : '',
00059             # Properties of the original image
00060             'srcWidth' => $image->getWidth(),
00061             'srcHeight' => $image->getHeight(),
00062             'mimeType' => $image->getMimeType(),
00063             'dstPath' => $dstPath,
00064             'dstUrl' => $dstUrl,
00065         );
00066 
00067         # In some cases, we do not bother generating a thumbnail.
00068         if ( !$image->mustRender() &&
00069             $scalerParams['physicalWidth'] == $scalerParams['srcWidth']
00070             && $scalerParams['physicalHeight'] == $scalerParams['srcHeight']
00071         ) {
00072             wfDebug( __METHOD__ . ": returning unscaled image\n" );
00073             // getClientScalingThumbnailImage is protected
00074             return $that->doClientImage( $image, $scalerParams );
00075         }
00076 
00077         return new ThumbnailImage( $image, $dstUrl, false, $params );
00078     }
00079 }