From 1a4957e0b4992891d35b06d2bb5d6ecf12ca4c29 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 9 Nov 2010 12:25:57 +0000 Subject: [PATCH] * (bug 21364) External links using link= attribute on images now respect $wgExternalLinkTarget --- RELEASE-NOTES | 2 ++ includes/Linker.php | 4 ++++ includes/media/MediaTransformOutput.php | 4 ++++ includes/parser/Parser.php | 3 +++ 4 files changed, 13 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ab0650df44..43c50c15f0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -410,6 +410,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes. * (bug 13353) Diff3 version checks were too strict, did not detect working diff3 * (bug 25843) Links to special pages using link= attribute on images are now normalised like normal links to special pages +* (bug 21364) External links using link= attribute on images now respect + $wgExternalLinkTarget === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent. diff --git a/includes/Linker.php b/includes/Linker.php index 0a460b036d..476878e814 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -428,6 +428,7 @@ class Linker { * caption HTML for image caption. * link-url URL to link to * link-title Title object to link to + * link-target Value for the target attribue, only with link-url * no-link Boolean, suppress description link * * @param $handlerParams Array: associative array of media handler parameters, to be passed @@ -552,6 +553,9 @@ class Linker { $mtoParams = array(); if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) { $mtoParams['custom-url-link'] = $frameParams['link-url']; + if ( isset( $frameParams['link-target'] ) ) { + $mtoParams['custom-target-link'] = $frameParams['link-target']; + } } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) { $mtoParams['custom-title-link'] = $this->normaliseSpecialPage( $frameParams['link-title'] ); } elseif ( !empty( $frameParams['no-link'] ) ) { diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index 276d254415..c441f06c92 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -144,6 +144,7 @@ class ThumbnailImage extends MediaTransformOutput { * desc-query String, description link query params * custom-url-link Custom URL to link to * custom-title-link Custom Title object to link to + * custom target-link Value of the target attribute, for custom-target-link * * For images, desc-link and file-link are implemented as a click-through. For * sounds and videos, they may be displayed in other ways. @@ -164,6 +165,9 @@ class ThumbnailImage extends MediaTransformOutput { if ( !empty( $options['title'] ) ) { $linkAttribs['title'] = $options['title']; } + if ( !empty( $options['custom-target-link'] ) ) { + $linkAttribs['target'] = $options['custom-target-link']; + } } elseif ( !empty( $options['custom-title-link'] ) ) { $title = $options['custom-title-link']; $linkAttribs = array( diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 1e2b3afef6..4a8352463d 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4694,6 +4694,9 @@ class Parser { if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) { $paramName = 'link-url'; $this->mOutput->addExternalLink( $value ); + if ( $this->mOptions->getExternalLinkTarget() ) { + $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget(); + } $validated = true; } } else { -- 2.20.1