MediaWiki  master
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 }
Mock handler for images.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Media transform output for images.
$params
static doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags=0)
Override BitmapHandler::doTransform() making sure we do not generate a thumbnail at all...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:780