Manual:Hooks/ImageBeforeProduceHTML

From MediaWiki.org
Jump to navigation Jump to search
ImageBeforeProduceHTML
Available from version 1.13.0
Called before producing the HTML created by a wiki image insertion
Define function:
public static function onImageBeforeProduceHTML( Skin &$skin, Title &$title, &$file, array &$frameParams, array &$handlerParams, &$time, &$result, Parser $parser, string &$query, &$widthOption ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ImageBeforeProduceHTML": "MyExtensionHooks::onImageBeforeProduceHTML"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ImageBeforeProduceHTML'][] = 'MyExtensionHooks::onImageBeforeProduceHTML';
Called from:File(s): Linker.php
Function(s): makeImageLink

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.

  • &$skin: Skin 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)