Jump to content

Manual:Hooks/LinkerMakeExternalImage

From mediawiki.org
LinkerMakeExternalImage
Available from version 1.13.0
Called before the HTML for external images is returned, used for modifying external image HTML
Define function:
public static function onLinkerMakeExternalImage( &$url, &$alt, &$img ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"LinkerMakeExternalImage": "MediaWiki\\Extension\\MyExtension\\Hooks::onLinkerMakeExternalImage"
	}
}
Called from: File(s): Linker.php
Interface: LinkerMakeExternalImageHook.php

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

Details

[edit]
  • &$url: The URL of the external image
  • &$alt: The alt text of the image
  • &$img: The image HTML if you choose to override the default.

You need to return false if you want to modify the HTML of external images, returning true will produce the normal external image HTML, regardless of if $img is set to something. Please note that you will need to include all parts of the HTML in $img, including the <img> tag, if you choose to return false.