From 088c6db48b8e2997cd496f131fa3bc789dba3da0 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Sun, 10 Jun 2018 18:31:56 +0300 Subject: [PATCH] Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook This allows extensions to essentially reimplement Linker#makeImageLink completely. Before this wasn't 100% possible as these three are needed for that. Inspired by wikiHow's core hacks to /includes/Linker.php, which can now be moved to an ImageBeforeProduceHTML hook subscriber. wikiHow uses those changes together with the WikihowArticle extension to heavily modify the article DOM for various extensions and the default skin. Change-Id: I8b5ab42d9cf021d66b90d15be68a0239643c10e3 --- RELEASE-NOTES-1.32 | 3 +++ docs/hooks.txt | 3 +++ includes/Linker.php | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index cdc25827f3..e276a19c78 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -41,6 +41,9 @@ production. reauthenticating. * FormSpecialPage::execute() will now call checkLoginSecurityLevel() if getLoginSecurityLevel() returns non-false. +* The 'ImageBeforeProduceHTML' hook is now passed three new parameters, $parser, + &$query and &$widthOption, allowing extensions even finer control over the resulting + HTML code. === External library changes in 1.32 === * … diff --git a/docs/hooks.txt b/docs/hooks.txt index 8c84509b56..bd237e625a 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1826,6 +1826,9 @@ just modify a few things using call-by-reference. includes/Linker.php for Linker::makeImageLink &$time: Timestamp of file in 'YYYYMMDDHHIISS' string form, or false for current &$res: Final HTML output, used if you return false +$parser: Parser instance +&$query: Query params for desc URL +&$widthOption: Used by the parser to remember the user preference thumbnailsize 'ImageOpenShowImageInlineBefore': Call potential extension just before showing the image on an image page. diff --git a/includes/Linker.php b/includes/Linker.php index 96385028d7..b50ccfcbf3 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -328,7 +328,9 @@ class Linker { $res = null; $dummy = new DummyLinker; if ( !Hooks::run( 'ImageBeforeProduceHTML', [ &$dummy, &$title, - &$file, &$frameParams, &$handlerParams, &$time, &$res ] ) ) { + &$file, &$frameParams, &$handlerParams, &$time, &$res, + $parser, &$query, &$widthOption + ] ) ) { return $res; } -- 2.20.1