MediaWiki  master
MediaHandler.php
Go to the documentation of this file.
1 <?php
22 
37 abstract class MediaHandler {
38  public const TRANSFORM_LATER = 1;
39  public const METADATA_GOOD = true;
40  public const METADATA_BAD = false;
41  public const METADATA_COMPATIBLE = 2; // for old but backwards compatible.
45  private const MAX_ERR_LOG_SIZE = 65535;
46 
53  public static function getHandler( $type ) {
54  return MediaWikiServices::getInstance()
55  ->getMediaHandlerFactory()->getHandler( $type );
56  }
57 
62  abstract public function getParamMap();
63 
72  abstract public function validateParam( $name, $value );
73 
80  abstract public function makeParamString( $params );
81 
88  abstract public function parseParamString( $str );
89 
97  abstract public function normaliseParams( $image, &$params );
98 
121  public function getImageSize( $image, $path ) {
122  return false;
123  }
124 
150  public function getSizeAndMetadata( $state, $path ) {
151  return null;
152  }
153 
163  public function getMetadata( $image, $path ) {
164  return '';
165  }
166 
176  protected function useLegacyMetadata() {
177  return $this->hasMostDerivedMethod( 'getMetadata' )
178  || $this->hasMostDerivedMethod( 'getImageSize' );
179  }
180 
188  protected function hasMostDerivedMethod( $name ) {
189  $rc = new ReflectionClass( $this );
190  $rm = new ReflectionMethod( $this, $name );
191  if ( $rm->getDeclaringClass()->getName() === $rc->getName() ) {
192  return true;
193  } else {
194  return false;
195  }
196  }
197 
218  final public function getSizeAndMetadataWithFallback( $file, $path ) {
219  if ( !$this->useLegacyMetadata() ) {
220  if ( $file instanceof MediaHandlerState ) {
221  $state = $file;
222  } else {
223  $state = new TrivialMediaHandlerState;
224  }
225  $info = $this->getSizeAndMetadata( $state, $path );
226  if ( $info === false ) {
227  return false;
228  }
229  if ( $info !== null ) {
230  if ( !is_array( $info['metadata'] ) ) {
231  throw new InvalidArgumentException( 'Media handler ' .
232  static::class . ' returned ' . gettype( $info['metadata'] ) .
233  ' for metadata, should be array' );
234  }
235  return $info + [ 'width' => 0, 'height' => 0, 'metadata' => [] ];
236  }
237  }
238 
239  $blob = $this->getMetadata( $file, $path );
240  // @phan-suppress-next-line PhanParamTooMany
241  $size = $this->getImageSize(
242  $file,
243  $path,
244  $blob // Secret TimedMediaHandler parameter
245  );
246  if ( $blob === false && $size === false ) {
247  return false;
248  }
249  if ( $size ) {
250  $info = [
251  'width' => $size[0] ?? 0,
252  'height' => $size[1] ?? 0
253  ];
254  if ( isset( $size['bits'] ) ) {
255  $info['bits'] = $size['bits'];
256  }
257  } else {
258  $info = [ 'width' => 0, 'height' => 0 ];
259  }
260  if ( $blob !== false ) {
261  // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
262  $metadata = @unserialize( $blob );
263  if ( $metadata === false ) {
264  // Unserialize error
265  $metadata = [ '_error' => $blob ];
266  } elseif ( !is_array( $metadata ) ) {
267  $metadata = [];
268  }
269  $info['metadata'] = $metadata;
270  } else {
271  $info['metadata'] = [];
272  }
273  return $info;
274  }
275 
293  public static function getMetadataVersion() {
294  $version = [ '2' ]; // core metadata version
295  Hooks::runner()->onGetMetadataVersion( $version );
296 
297  return implode( ';', $version );
298  }
299 
311  public function convertMetadataVersion( $metadata, $version = 1 ) {
312  return $metadata;
313  }
314 
323  public function getMetadataType( $image ) {
324  return false;
325  }
326 
345  public function isMetadataValid( $image, $metadata ) {
346  return self::METADATA_GOOD;
347  }
348 
374  public function isFileMetadataValid( $image ) {
375  return self::METADATA_GOOD;
376  }
377 
412  public function getCommonMetaArray( File $file ) {
413  return false;
414  }
415 
431  public function getScriptedTransform( $image, $script, $params ) {
432  return false;
433  }
434 
447  final public function getTransform( $image, $dstPath, $dstUrl, $params ) {
448  return $this->doTransform( $image, $dstPath, $dstUrl, $params, self::TRANSFORM_LATER );
449  }
450 
465  abstract public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 );
466 
477  public function getThumbType( $ext, $mime, $params = null ) {
478  $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
479  if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
480  // The extension is not valid for this MIME type and we do
481  // recognize the MIME type
482  $knownExt = $magic->getExtensionFromMimeTypeOrNull( $mime );
483  if ( $knownExt !== null ) {
484  return [ $knownExt, $mime ];
485  }
486  }
487 
488  // The extension is correct (true) or the MIME type is unknown to
489  // MediaWiki (null)
490  return [ $ext, $mime ];
491  }
492 
501  public function canRender( $file ) {
502  return true;
503  }
504 
514  public function mustRender( $file ) {
515  return false;
516  }
517 
526  public function isMultiPage( $file ) {
527  return false;
528  }
529 
538  public function pageCount( File $file ) {
539  return false;
540  }
541 
550  public function isVectorized( $file ) {
551  return false;
552  }
553 
564  public function isAnimatedImage( $file ) {
565  return false;
566  }
567 
577  public function canAnimateThumbnail( $file ) {
578  return true;
579  }
580 
587  public function isEnabled() {
588  return true;
589  }
590 
608  public function getPageDimensions( File $image, $page ) {
609  return false;
610  }
611 
622  public function getPageText( File $image, $page ) {
623  return false;
624  }
625 
631  public function getEntireText( File $file ) {
632  $numPages = $file->pageCount();
633  if ( !$numPages ) {
634  // Not a multipage document
635  return $this->getPageText( $file, 1 );
636  }
637  $document = '';
638  for ( $i = 1; $i <= $numPages; $i++ ) {
639  $curPage = $this->getPageText( $file, $i );
640  if ( is_string( $curPage ) ) {
641  $document .= $curPage . "\n";
642  }
643  }
644  if ( $document !== '' ) {
645  return $document;
646  }
647  return false;
648  }
649 
680  public function formatMetadata( $image, $context = false ) {
681  return false;
682  }
683 
696  protected function formatMetadataHelper( $metadataArray, $context = false ) {
697  $result = [
698  'visible' => [],
699  'collapsed' => []
700  ];
701 
702  // Allow this MediaHandler to override formatting on certain values
703  foreach ( $metadataArray as $tag => $vals ) {
704  $v = $this->formatTag( $tag, $vals, $context );
705  if ( $v === false ) {
706  // Use default formatting
707  continue;
708  } elseif ( $v === null ) {
709  // Remove this tag, don't format it for display
710  unset( $metadataArray[$tag] );
711  } else {
712  // Allow subclass to override default formatting.
713  $metadataArray[$tag] = [ '_formatted' => $v ];
714  if ( isset( $v['_type'] ) ) {
715  $metadataArray[$tag]['_type'] = $v['_type'];
716  unset( $metadataArray[$tag]['_formatted']['_type'] );
717  }
718  }
719  }
720 
721  $formatted = FormatMetadata::getFormattedData( $metadataArray, $context );
722  // Sort fields into visible and collapsed
723  $visibleFields = $this->visibleMetadataFields();
724  foreach ( $formatted as $name => $value ) {
725  $tag = strtolower( $name );
726  self::addMeta( $result,
727  in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
728  'exif',
729  $tag,
730  $value
731  );
732  }
733 
734  return $result;
735  }
736 
749  protected function formatTag( string $key, $vals, $context = false ) {
750  return false; // Use default formatting
751  }
752 
761  protected function visibleMetadataFields() {
763  }
764 
788  protected static function addMeta( &$array, $visibility, $type, $id, $value, $param = false ) {
789  $msg = wfMessage( "$type-$id", $param );
790  if ( $msg->exists() ) {
791  $name = $msg->text();
792  } else {
793  // This is for future compatibility when using instant commons.
794  // So as to not display as ugly a name if a new metadata
795  // property is defined that we don't know about
796  // (not a major issue since such a property would be collapsed
797  // by default).
798  wfDebug( __METHOD__ . ' Unknown metadata name: ' . $id );
799  $name = wfEscapeWikiText( $id );
800  }
801  $array[$visibility][] = [
802  'id' => "$type-$id",
803  'name' => $name,
804  'value' => $value
805  ];
806  }
807 
816  public function getShortDesc( $file ) {
818  }
819 
828  public function getLongDesc( $file ) {
830  }
831 
838  public static function getGeneralShortDesc( $file ) {
839  global $wgLang;
840 
841  return htmlspecialchars( $wgLang->formatSize( $file->getSize() ) );
842  }
843 
850  public static function getGeneralLongDesc( $file ) {
851  return wfMessage( 'file-info' )->sizeParams( $file->getSize() )
852  ->params( '<span class="mime-type">' . $file->getMimeType() . '</span>' )->parse();
853  }
854 
863  public static function fitBoxWidth( $boxWidth, $boxHeight, $maxHeight ) {
864  $idealWidth = $boxWidth * $maxHeight / $boxHeight;
865  $roundedUp = ceil( $idealWidth );
866  if ( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight ) {
867  return floor( $idealWidth );
868  } else {
869  return $roundedUp;
870  }
871  }
872 
881  public function getDimensionsString( $file ) {
882  return '';
883  }
884 
897  public function parserTransformHook( $parser, $file ) {
898  }
899 
912  public function verifyUpload( $fileName ) {
913  return Status::newGood();
914  }
915 
926  public function removeBadFile( $dstPath, $retval = 0 ) {
927  if ( file_exists( $dstPath ) ) {
928  $thumbstat = stat( $dstPath );
929  if ( $thumbstat['size'] == 0 || $retval != 0 ) {
930  $result = unlink( $dstPath );
931 
932  if ( $result ) {
933  wfDebugLog( 'thumbnail',
934  sprintf( 'Removing bad %d-byte thumbnail "%s". unlink() succeeded',
935  $thumbstat['size'], $dstPath ) );
936  } else {
937  wfDebugLog( 'thumbnail',
938  sprintf( 'Removing bad %d-byte thumbnail "%s". unlink() failed',
939  $thumbstat['size'], $dstPath ) );
940  }
941 
942  return true;
943  }
944  }
945 
946  return false;
947  }
948 
963  public function filterThumbnailPurgeList( &$files, $options ) {
964  // Do nothing
965  }
966 
974  public function canRotate() {
975  return false;
976  }
977 
994  public function getRotation( $file ) {
995  return 0;
996  }
997 
1009  protected function logErrorForExternalProcess( $retval, $err, $cmd ) {
1010  # Keep error output limited (T59985)
1011  $errMessage = trim( substr( $err, 0, self::MAX_ERR_LOG_SIZE ) );
1012 
1013  wfDebugLog( 'thumbnail',
1014  sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
1015  wfHostname(), $retval, $errMessage, $cmd ) );
1016  }
1017 
1027  public function getAvailableLanguages( File $file ) {
1028  return [];
1029  }
1030 
1042  public function getMatchedLanguage( $userPreferredLanguage, array $availableLanguages ) {
1043  return null;
1044  }
1045 
1060  public function getDefaultRenderLanguage( File $file ) {
1061  return null;
1062  }
1063 
1076  public function getLength( $file ) {
1077  return 0.0;
1078  }
1079 
1087  public function isExpensiveToThumbnail( $file ) {
1088  return false;
1089  }
1090 
1099  public function supportsBucketing() {
1100  return false;
1101  }
1102 
1111  public function sanitizeParamsForBucketing( $params ) {
1112  return $params;
1113  }
1114 
1141  public function getWarningConfig( $file ) {
1142  return null;
1143  }
1144 
1152  public static function getPageRangesByDimensions( $pagesByDimensions ) {
1153  $pageRangesByDimensions = [];
1154 
1155  foreach ( $pagesByDimensions as $dimensions => $pageList ) {
1156  $ranges = [];
1157  $firstPage = $pageList[0];
1158  $lastPage = $firstPage - 1;
1159 
1160  foreach ( $pageList as $page ) {
1161  if ( $page > $lastPage + 1 ) {
1162  if ( $firstPage != $lastPage ) {
1163  $ranges[] = "$firstPage-$lastPage";
1164  } else {
1165  $ranges[] = "$firstPage";
1166  }
1167 
1168  $firstPage = $page;
1169  }
1170 
1171  $lastPage = $page;
1172  }
1173 
1174  if ( $firstPage != $lastPage ) {
1175  $ranges[] = "$firstPage-$lastPage";
1176  } else {
1177  $ranges[] = "$firstPage";
1178  }
1179 
1180  $pageRangesByDimensions[ $dimensions ] = $ranges;
1181  }
1182 
1183  $dimensionsString = [];
1184  foreach ( $pageRangesByDimensions as $dimensions => $pageRanges ) {
1185  $dimensionsString[] = "$dimensions:" . implode( ',', $pageRanges );
1186  }
1187 
1188  return implode( '/', $dimensionsString );
1189  }
1190 
1199  public function getContentHeaders( $metadata ) {
1200  return [ 'X-Content-Dimensions' => '' ]; // T175689
1201  }
1202 }
MediaHandler\removeBadFile
removeBadFile( $dstPath, $retval=0)
Check for zero-sized thumbnails.
Definition: MediaHandler.php:926
MediaHandler\mustRender
mustRender( $file)
True if handled types cannot be displayed directly in a browser but can be rendered.
Definition: MediaHandler.php:514
MediaHandler\formatMetadata
formatMetadata( $image, $context=false)
Get an array structure that looks like this:
Definition: MediaHandler.php:680
MediaHandler\useLegacyMetadata
useLegacyMetadata()
If this returns true, the new method getSizeAndMetadata() will not be called.
Definition: MediaHandler.php:176
MediaHandler\getWarningConfig
getWarningConfig( $file)
Gets configuration for the file warning message.
Definition: MediaHandler.php:1141
MediaHandler\getCommonMetaArray
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
Definition: MediaHandler.php:412
MediaHandler\normaliseParams
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.
MediaHandler\verifyUpload
verifyUpload( $fileName)
File validation hook called on upload.
Definition: MediaHandler.php:912
MediaHandler\pageCount
pageCount(File $file)
Page count for a multi-page document, false if unsupported or unknown.
Definition: MediaHandler.php:538
FormatMetadata\getFormattedData
static getFormattedData( $tags, $context=false)
Numbers given by Exif user agents are often magical, that is they should be replaced by a detailed ex...
Definition: FormatMetadata.php:87
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:180
MediaHandler\TRANSFORM_LATER
const TRANSFORM_LATER
Definition: MediaHandler.php:38
MediaHandler\getMetadataVersion
static getMetadataVersion()
Get metadata version.
Definition: MediaHandler.php:293
MediaHandler\filterThumbnailPurgeList
filterThumbnailPurgeList(&$files, $options)
Remove files from the purge list.
Definition: MediaHandler.php:963
MediaHandler\getEntireText
getEntireText(File $file)
Get the text of the entire document.
Definition: MediaHandler.php:631
MediaHandler\getShortDesc
getShortDesc( $file)
Short description.
Definition: MediaHandler.php:816
MediaHandler\MAX_ERR_LOG_SIZE
const MAX_ERR_LOG_SIZE
Max length of error logged by logErrorForExternalProcess()
Definition: MediaHandler.php:45
TrivialMediaHandlerState
Trivial implementation of MediaHandlerState.
Definition: TrivialMediaHandlerState.php:8
MediaHandler\getThumbType
getThumbType( $ext, $mime, $params=null)
Get the thumbnail extension and MIME type for a given source MIME type.
Definition: MediaHandler.php:477
MediaHandler\canRotate
canRotate()
True if the handler can rotate the media.
Definition: MediaHandler.php:974
MediaHandler\getMatchedLanguage
getMatchedLanguage( $userPreferredLanguage, array $availableLanguages)
When overridden in a descendant class, returns a language code most suiting.
Definition: MediaHandler.php:1042
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
wfHostname
wfHostname()
Get host name of the current machine, for use in error reporting.
Definition: GlobalFunctions.php:1245
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1182
MediaHandler\hasMostDerivedMethod
hasMostDerivedMethod( $name)
Check whether a method is implemented in the most derived class.
Definition: MediaHandler.php:188
MediaHandler\getLongDesc
getLongDesc( $file)
Long description.
Definition: MediaHandler.php:828
$wgLang
$wgLang
Definition: Setup.php:796
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:958
MediaHandler\supportsBucketing
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
Definition: MediaHandler.php:1099
MediaHandler\getMetadataType
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
Definition: MediaHandler.php:323
MediaHandler\getAvailableLanguages
getAvailableLanguages(File $file)
Get list of languages file can be viewed in.
Definition: MediaHandler.php:1027
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:241
MediaHandler\makeParamString
makeParamString( $params)
Merge a parameter array into a string appropriate for inclusion in filenames.
MediaHandler\METADATA_COMPATIBLE
const METADATA_COMPATIBLE
Definition: MediaHandler.php:41
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:66
MediaHandler\isExpensiveToThumbnail
isExpensiveToThumbnail( $file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition: MediaHandler.php:1087
MediaHandler\getPageRangesByDimensions
static getPageRangesByDimensions( $pagesByDimensions)
Converts a dimensions array about a potentially multipage document from an exhaustive list of ordered...
Definition: MediaHandler.php:1152
$blob
$blob
Definition: testCompression.php:70
MediaHandler\canAnimateThumbnail
canAnimateThumbnail( $file)
If the material is animated, we can animate the thumbnail.
Definition: MediaHandler.php:577
MediaHandler\getPageText
getPageText(File $image, $page)
Generic getter for text layer.
Definition: MediaHandler.php:622
MediaHandler\isFileMetadataValid
isFileMetadataValid( $image)
Check if the metadata is valid for this handler.
Definition: MediaHandler.php:374
MediaHandler\addMeta
static addMeta(&$array, $visibility, $type, $id, $value, $param=false)
This is used to generate an array element for each metadata value That array is then used to generate...
Definition: MediaHandler.php:788
MediaHandler\getPageDimensions
getPageDimensions(File $image, $page)
Get an associative array of page dimensions Currently "width" and "height" are understood,...
Definition: MediaHandler.php:608
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:894
MediaHandler\getImageSize
getImageSize( $image, $path)
Get an image size array like that returned by getimagesize(), or false if it can't be determined.
Definition: MediaHandler.php:121
MediaHandler\isEnabled
isEnabled()
False if the handler is disabled for all files.
Definition: MediaHandler.php:587
MediaHandler\getDimensionsString
getDimensionsString( $file)
Shown in file history box on image description page.
Definition: MediaHandler.php:881
MediaHandler\getMetadata
getMetadata( $image, $path)
Get handler-specific metadata which will be saved in the img_metadata field.
Definition: MediaHandler.php:163
MediaHandler\convertMetadataVersion
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
Definition: MediaHandler.php:311
MediaHandler\getGeneralShortDesc
static getGeneralShortDesc( $file)
Used instead of getShortDesc if there is no handler registered for file.
Definition: MediaHandler.php:838
MediaHandler\getSizeAndMetadataWithFallback
getSizeAndMetadataWithFallback( $file, $path)
Get the metadata array and the image size, with b/c fallback.
Definition: MediaHandler.php:218
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
MediaHandler\getTransform
getTransform( $image, $dstPath, $dstUrl, $params)
Get a MediaTransformOutput object representing the transformed output.
Definition: MediaHandler.php:447
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:172
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1456
MediaHandler\doTransform
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Get a MediaTransformOutput object representing the transformed output.
unserialize
unserialize( $serialized)
Definition: ApiMessageTrait.php:146
MediaHandler\visibleMetadataFields
visibleMetadataFields()
Get a list of metadata items which should be displayed when the metadata table is collapsed.
Definition: MediaHandler.php:761
MediaHandler\getParamMap
getParamMap()
Get an associative array mapping magic word IDs to parameter names.
MediaHandler\getContentHeaders
getContentHeaders( $metadata)
Get useful response headers for GET/HEAD requests for a file with the given metadata.
Definition: MediaHandler.php:1199
MediaHandler\logErrorForExternalProcess
logErrorForExternalProcess( $retval, $err, $cmd)
Log an error that occurred in an external process.
Definition: MediaHandler.php:1009
MediaHandler\formatTag
formatTag(string $key, $vals, $context=false)
Override default formatting for the given metadata field.
Definition: MediaHandler.php:749
MediaHandler\formatMetadataHelper
formatMetadataHelper( $metadataArray, $context=false)
sorts the visible/invisible field.
Definition: MediaHandler.php:696
$path
$path
Definition: NoLocalSettings.php:25
MediaHandler\getHandler
static getHandler( $type)
Get a MediaHandler for a given MIME type from the instance cache.
Definition: MediaHandler.php:53
MediaHandler\parserTransformHook
parserTransformHook( $parser, $file)
Modify the parser object post-transform.
Definition: MediaHandler.php:897
MediaHandler\sanitizeParamsForBucketing
sanitizeParamsForBucketing( $params)
Returns a normalised params array for which parameters have been cleaned up for bucketing purposes.
Definition: MediaHandler.php:1111
MediaHandler\getSizeAndMetadata
getSizeAndMetadata( $state, $path)
Get image size information and metadata array.
Definition: MediaHandler.php:150
MediaHandler\isAnimatedImage
isAnimatedImage( $file)
The material is an image, and is animated.
Definition: MediaHandler.php:564
MediaHandler\parseParamString
parseParamString( $str)
Parse a param string made with makeParamString back into an array.
MediaHandler\METADATA_BAD
const METADATA_BAD
Definition: MediaHandler.php:40
MediaHandler\canRender
canRender( $file)
True if the handled types can be transformed.
Definition: MediaHandler.php:501
MediaHandler\isVectorized
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
Definition: MediaHandler.php:550
MediaHandler\getScriptedTransform
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
Definition: MediaHandler.php:431
$ext
if(!is_readable( $file)) $ext
Definition: router.php:48
MediaHandler\getGeneralLongDesc
static getGeneralLongDesc( $file)
Used instead of getLongDesc if there is no handler registered for file.
Definition: MediaHandler.php:850
MediaHandler\fitBoxWidth
static fitBoxWidth( $boxWidth, $boxHeight, $maxHeight)
Calculate the largest thumbnail width for a given original file size such that the thumbnail's height...
Definition: MediaHandler.php:863
$mime
$mime
Definition: router.php:60
MediaHandler\validateParam
validateParam( $name, $value)
Validate a thumbnail parameter at parse time.
FormatMetadata\getVisibleFields
static getVisibleFields()
Get a list of fields that are visible by default.
Definition: FormatMetadata.php:1713
MediaHandlerState
An interface to support process-local caching of handler data associated with a given file.
Definition: MediaHandlerState.php:10
MediaHandler\isMetadataValid
isMetadataValid( $image, $metadata)
Check if the metadata string is valid for this handler.
Definition: MediaHandler.php:345
MediaHandler\isMultiPage
isMultiPage( $file)
True if the type has multi-page capabilities.
Definition: MediaHandler.php:526
MediaHandler\getRotation
getRotation( $file)
On supporting image formats, try to read out the low-level orientation of the file and return the ang...
Definition: MediaHandler.php:994
MediaHandler
Base media handler class.
Definition: MediaHandler.php:37
MediaHandler\getLength
getLength( $file)
If its an audio file, return the length of the file.
Definition: MediaHandler.php:1076
MediaHandler\METADATA_GOOD
const METADATA_GOOD
Definition: MediaHandler.php:39
MediaHandler\getDefaultRenderLanguage
getDefaultRenderLanguage(File $file)
On file types that support renderings in multiple languages, which language is used by default if uns...
Definition: MediaHandler.php:1060
$type
$type
Definition: testCompression.php:52