Manual:Hooks/MimeMagicGuessFromContent

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": "MediaWiki\\Extension\\MyExtension\\Hooks::onMimeMagicGuessFromContent"
	}
}
Called from: File(s): ServiceWiring.php
Function(s): MimeAnalyzer::guessCallback
Interface: MimeMagicGuessFromContentHook.php

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).