Manual:Hooks/MimeMagicInit

From Linux Web Expert

MimeMagicInit
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 141240)</tvar></translate>
Before processing the list mapping MIME types to media types and the list mapping MIME types to file extensions. As an extension author, you are encouraged to submit patches to MediaWiki's core to add new MIME types to mime.types.
<translate> Define function:</translate>
public static function onMimeMagicInit( $mime ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"MimeMagicInit": "MediaWiki\\Extension\\MyExtension\\Hooks::onMimeMagicInit"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> ServiceWiring.php
<translate> Function(s):</translate> MimeAnalyzer::initCallback
<translate> Interface:</translate> MimeMagicInitHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:MimeMagicInit extensions</tvar>.</translate>


Details

$mime: Instance of MimeAnalyzer; $mime->addExtraTypes( 'application/xml svg' );

  • Use $mime->addExtraInfo( $stringOfInfo ); to add new MIME info to the list.
  • Use $mime->addExtraTypes( $stringOfTypes ); to add new MIME types to the list.

See also