Manual:Hooks/MimeMagicGuessFromContent

From MediaWiki.org
Jump to navigation Jump to search
MimeMagicGuessFromContent
Available from version 1.24.0 (Gerrit change 141240)
Allows MW extensions guess the MIME by content.
Define function:
public static function onMimeMagicGuessFromContent( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"MimeMagicGuessFromContent": "MyExtensionHooks::onMimeMagicGuessFromContent"
	}
}

For MediaWiki ≤1.25:

$wgHooks['MimeMagicGuessFromContent'][] = 'MyExtensionHooks::onMimeMagicGuessFromContent';
Called from:File(s): ServiceWiring.php
Function(s): MimeAnalyzer::guessCallback

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:MimeMagicGuessFromContent extensions.

Details[edit]

$mimeMagic
Instance of MimeMagic.
&$head
First 1024 bytes of the file in a string (in - Do not alter!).
&$tail
More or equal than last 65558 bytes of the file in a string (input only - passed by reference for performance - do not alter!).
$file
File path.
&$mime
MIME type (out).