From b207c900fa714dab3c09c4e14404224f0c0e430c Mon Sep 17 00:00:00 2001 From: nischayn22 Date: Wed, 7 Nov 2012 10:49:57 +0530 Subject: [PATCH] Hook to allow manipulation of image data Adds a new hook, ThumbnailBeforeProduceHTML, to ThumbnailImage::toHtml method, in order to permit the user to manipulate the image and link attributes before the HTML is rendered. For details see bug 41835 Note: Patch given by Victor Change-Id: Ib94967997e1303522d0081c7387e29af9c0ef0f0 --- docs/hooks.txt | 5 +++++ includes/media/MediaTransformOutput.php | 3 +++ 2 files changed, 8 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index d02118fede..5bc3b41c01 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2107,6 +2107,11 @@ $request: WebRequest $title: Title of the currently found title obj $output: OutputPage object +'ThumbnailBeforeProduceHTML': called before an image HTML is about to be rendered (by ThumbnailImage:toHtml method) +$thumbnail: the ThumbnailImage object +&$attribs: image attibute array +&$linkAttribs: image link attribute array + 'TitleArrayFromResult': called when creating an TitleArray object from a database result &$titleArray: set this to an object to override the default object returned diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index 97a2d1d136..7301df6c9b 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -347,6 +347,9 @@ class ThumbnailImage extends MediaTransformOutput { if ( !empty( $this->responsiveUrls ) ) { $attribs['srcset'] = Html::srcSet( $this->responsiveUrls ); } + + wfRunHooks( 'ThumbnailBeforeProduceHTML', array( $this, &$attribs, &$linkAttribs ) ); + return $this->linkWrap( $linkAttribs, Xml::element( 'img', $attribs ) ); } -- 2.20.1