Go to the documentation of this file.
35 return (
$file->getWidth() &&
$file->getHeight() );
39 return [
'img_width' =>
'width' ];
43 if ( in_array( $name, [
'width',
'height' ] ) ) {
55 if ( isset( $params[
'physicalWidth'] ) ) {
56 $width = $params[
'physicalWidth'];
57 } elseif ( isset( $params[
'width'] ) ) {
58 $width = $params[
'width'];
63 # Removed for ProofreadPage
64 # $width = intval( $width );
70 if ( preg_match(
'/^(\d+)px$/', $str, $m ) ) {
71 return [
'width' => $m[1] ];
78 return [
'width' => $params[
'width'] ];
87 $mimeType = $image->getMimeType();
89 if ( !isset( $params[
'width'] ) ) {
93 if ( !isset( $params[
'page'] ) ) {
96 $params[
'page'] = intval( $params[
'page'] );
97 if ( $params[
'page'] > $image->pageCount() ) {
98 $params[
'page'] = $image->pageCount();
101 if ( $params[
'page'] < 1 ) {
106 $srcWidth = $image->getWidth( $params[
'page'] );
107 $srcHeight = $image->getHeight( $params[
'page'] );
109 if ( isset( $params[
'height'] ) && $params[
'height'] != -1 ) {
110 # Height & width were both set
111 if ( $params[
'width'] * $srcHeight > $params[
'height'] * $srcWidth ) {
112 # Height is the relative smaller dimension, so scale width accordingly
113 $params[
'width'] =
self::fitBoxWidth( $srcWidth, $srcHeight, $params[
'height'] );
115 if ( $params[
'width'] == 0 ) {
116 # Very small image, so we need to rely on client side scaling :(
117 $params[
'width'] = 1;
120 $params[
'physicalWidth'] = $params[
'width'];
122 # Height was crap, unset it so that it will be calculated later
123 unset( $params[
'height'] );
127 if ( !isset( $params[
'physicalWidth'] ) ) {
128 # Passed all validations, so set the physicalWidth
129 $params[
'physicalWidth'] = $params[
'width'];
132 # Because thumbs are only referred to by width, the height always needs
133 # to be scaled by the width to keep the thumbnail sizes consistent,
134 # even if it was set inside the if block above
136 $params[
'physicalWidth'] );
138 # Set the height if it was not validated in the if block higher up
139 if ( !isset( $params[
'height'] ) || $params[
'height'] == -1 ) {
140 $params[
'height'] = $params[
'physicalHeight'];
144 $params[
'physicalHeight'], $srcWidth, $srcHeight, $mimeType )
163 $width = intval( $width );
165 # Sanity check $width
167 wfDebug( __METHOD__ .
": Invalid destination width: $width\n" );
171 if ( $srcWidth <= 0 ) {
172 wfDebug( __METHOD__ .
": Invalid source width: $srcWidth\n" );
178 if ( $height == 0 ) {
179 # Force height to be at least 1 pixel
198 if ( $image->mustRender() || $params[
'width'] < $image->getWidth() ) {
204 Wikimedia\suppressWarnings();
205 $gis = getimagesize(
$path );
206 Wikimedia\restoreWarnings();
221 return $image->getWidth() * $image->getHeight();
230 $nbytes = htmlspecialchars(
$wgLang->formatSize(
$file->getSize() ) );
231 $widthheight =
wfMessage(
'widthheight' )
232 ->numParams(
$file->getWidth(),
$file->getHeight() )->escaped();
234 return "$widthheight ($nbytes)";
243 $pages =
$file->pageCount();
244 $size = htmlspecialchars(
$wgLang->formatSize(
$file->getSize() ) );
245 if ( $pages ===
false || $pages <= 1 ) {
246 $msg =
wfMessage(
'file-info-size' )->numParams(
$file->getWidth(),
247 $file->getHeight() )->params( $size,
248 '<span class="mime-type">' .
$file->getMimeType() .
'</span>' )->parse();
250 $msg =
wfMessage(
'file-info-size-pages' )->numParams(
$file->getWidth(),
251 $file->getHeight() )->params( $size,
252 '<span class="mime-type">' .
$file->getMimeType() .
'</span>' )->numParams( $pages )->parse();
263 $pages =
$file->pageCount();
266 ->numParams(
$file->getWidth(),
$file->getHeight(), $pages )->text();
269 ->numParams(
$file->getWidth(),
$file->getHeight() )->text();
274 $params = parent::sanitizeParamsForBucketing( $params );
278 if ( isset( $params[
'height'] ) ) {
279 unset( $params[
'height'] );
282 if ( isset( $params[
'physicalHeight'] ) ) {
283 unset( $params[
'physicalHeight'] );
validateParam( $name, $value)
Validate a thumbnail parameter at parse time.
Media transform output for images.
parseParamString( $str)
Parse a param string made with makeParamString back into an array.
getScriptParams( $params)
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
getParamMap()
Get an associative array mapping magic word IDs to parameter names.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Media handler abstract base class for images.
sanitizeParamsForBucketing( $params)
Returns a normalised params array for which parameters have been cleaned up for bucketing purposes.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
validateThumbParams(&$width, &$height, $srcWidth, $srcHeight, $mimeType)
Validate thumbnail parameters and fill in the correct height.
getDimensionsString( $file)
normaliseParams( $image, &$params)
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
makeParamString( $params)
Merge a parameter array into a string appropriate for inclusion in filenames.
getImageSize( $image, $path)
Get an image size array like that returned by getimagesize(), or false if it can't be determined.
getScriptedTransform( $image, $script, $params)
getImageArea( $image)
Function that returns the number of pixels to be thumbnailed.