Jump to content

Manual:Hooks/ImageBeforeProduceHTML

From mediawiki.org
ImageBeforeProduceHTML
Available from version 1.13.0
Called before producing the HTML created by a wiki image insertion
Define function:
public static function onImageBeforeProduceHTML( DummyLinker &$linker, Title &$title, &$file, array &$frameParams, array &$handlerParams, &$time, &$result, Parser $parser, string &$query, &$widthOption ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ImageBeforeProduceHTML": "MediaWiki\\Extension\\MyExtension\\Hooks::onImageBeforeProduceHTML"
	}
}
Called from: File(s): Linker.php
Function(s): makeImageLink
Interface: ImageBeforeProduceHTMLHook.php

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


Details

[edit]

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 (introduced in 1.32.0)
  • &$query: Query params for desc URL (introduced in 1.32.0)
  • &$widthOption: Used by the parser to remember the user preference thumbnail size. Int or null (introduced in 1.32.0)