MediaWiki REL1_31
MockImageHandler.php
Go to the documentation of this file.
1<?php
32
46 static function doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
47 # Example of what we receive:
48 # $image: LocalFile
49 # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg
50 # $dstUrl : http://example.com/images/thumb/0/09/Bad.jpg/320px-Bad.jpg
51 # $params: width: 320, descriptionUrl http://trunk.dev/wiki/File:Bad.jpg
52
53 $that->normaliseParams( $image, $params );
54
55 $scalerParams = [
56 # The size to which the image will be resized
57 'physicalWidth' => $params['physicalWidth'],
58 'physicalHeight' => $params['physicalHeight'],
59 'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}",
60 # The size of the image on the page
61 'clientWidth' => $params['width'],
62 'clientHeight' => $params['height'],
63 # Comment as will be added to the EXIF of the thumbnail
64 'comment' => isset( $params['descriptionUrl'] ) ?
65 "File source: {$params['descriptionUrl']}" : '',
66 # Properties of the original image
67 'srcWidth' => $image->getWidth(),
68 'srcHeight' => $image->getHeight(),
69 'mimeType' => $image->getMimeType(),
70 'dstPath' => $dstPath,
71 'dstUrl' => $dstUrl,
72 ];
73
74 # In some cases, we do not bother generating a thumbnail.
75 if ( !$image->mustRender() &&
76 $scalerParams['physicalWidth'] == $scalerParams['srcWidth']
77 && $scalerParams['physicalHeight'] == $scalerParams['srcHeight']
78 ) {
79 wfDebug( __METHOD__ . ": returning unscaled image\n" );
80 // getClientScalingThumbnailImage is protected
81 return $that->doClientImage( $image, $scalerParams );
82 }
83
84 return new ThumbnailImage( $image, $dstUrl, false, $params );
85 }
86}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Mock handler for images.
static doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags=0)
Override BitmapHandler::doTransform() making sure we do not generate a thumbnail at all.
Media transform output for images.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
Definition hooks.txt:895
$params