From: Ryan Schmidt Date: Tue, 24 Jun 2008 14:32:49 +0000 (+0000) Subject: * add new hook LinkerMakeExternalImage to allow extensions to modify the HTML output... X-Git-Tag: 1.31.0-rc.0~46897 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=40ccb73c4d5fd3a733357f1381e712fe16eb5646;p=lhc%2Fweb%2Fwiklou.git * add new hook LinkerMakeExternalImage to allow extensions to modify the HTML output of external images --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 839f87e7d7..54c13c436e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -160,6 +160,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14558) New system message (emailuserfooter) is now added to the footer of e-mails sent with Special:Emailuser * Add support for Hijri (Islamic) calendar +* Add a new hook LinkerMakeExternalImage to allow extensions to modify the output of + external (hotlinked) images. === Bug fixes in 1.13 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 2357c654c2..c1475ac1b3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -731,6 +731,11 @@ $lang: laguage code (string) $specialPageAliases: associative array of magic words synonyms $lang: laguage code (string) +'LinkerMakeExternalImage': At the end of Linker::makeExternalImage() just before the return +&$url: the image url +&alt: the image's alt text +&$img: the new image HTML (if returning false) + 'LinkerMakeExternalLink': At the end of Linker::makeExternalLink() just before the return &$url: the link url &$text: the link text diff --git a/includes/Linker.php b/includes/Linker.php index 142cc5db18..f64f9e4085 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -456,6 +456,12 @@ class Linker { if ( '' == $alt ) { $alt = $this->fnamePart( $url ); } + $img = ''; + $success = wfRunHooks('LinkerMakeExternalImage', array( &$url, &$alt, &$img ) ); + if(!$success) { + wfDebug("Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}", true); + return $img; + } $s = ''.$alt.''; return $s; }