Manual:Hooks/ImageBeforeProduceHTML

From Linux Web Expert

ImageBeforeProduceHTML
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Called before producing the HTML created by a wiki image insertion
<translate> Define function:</translate>
public static function onImageBeforeProduceHTML( DummyLinker &$linker, Title &$title, &$file, array &$frameParams, array &$handlerParams, &$time, &$result, Parser $parser, string &$query, &$widthOption ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ImageBeforeProduceHTML": "MediaWiki\\Extension\\MyExtension\\Hooks::onImageBeforeProduceHTML"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> Linker.php
<translate> Function(s):</translate> makeImageLink
<translate> Interface:</translate> ImageBeforeProduceHTMLHook.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:ImageBeforeProduceHTML extensions</tvar>.</translate>


Details

You can skip the default logic entirely by returning false, or just modify a few things using call-by-reference.

  • &$linker: DummyLinker object
  • &$title: Title object of the image
  • &$file: File object, or false if it doesn't exist
  • &$frameParams: Various parameters with special meanings; see documentation in includes/Linker.php for Linker::makeImageLink
  • &$handlerParams: Various parameters with special meanings; see documentation in includes/Linker.php for Linker::makeImageLink
  • &$time: Timestamp of file in YYYYMMDDHHIISS string form, or false for current
  • &$result: Final HTML output (string, null by default), used if you return false
  • $parser: Parser object <translate> (introduced in <tvar
  • &$query: Query params for desc URL <translate> (introduced in <tvar
  • &$widthOption: Used by the parser to remember the user preference thumbnail size. Int or null <translate> (introduced in <tvar