From 4a46d001c5f250af3b8bcdfb4551d58227caab8f Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Sun, 10 Aug 2014 18:35:37 -0400 Subject: [PATCH] Always set a title on images when provided If an image has a title but isn't linked, set the title on the image itself rather than not setting it at all. Bug: T23454 Change-Id: I6302246cf28c84ade805a6a7d4a5e131b6f42e86 --- includes/media/MediaTransformOutput.php | 13 ++++++++----- tests/parser/parserTests.txt | 9 +++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index d9327fb5e1..304cc03e53 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -352,6 +352,11 @@ class ThumbnailImage extends MediaTransformOutput { $query = isset( $options['desc-query'] ) ? $options['desc-query'] : ''; + $attribs = array( + 'alt' => $alt, + 'src' => $this->url, + ); + if ( !empty( $options['custom-url-link'] ) ) { $linkAttribs = array( 'href' => $options['custom-url-link'] ); if ( !empty( $options['title'] ) ) { @@ -381,13 +386,11 @@ class ThumbnailImage extends MediaTransformOutput { $linkAttribs = array( 'href' => $this->file->getURL() ); } else { $linkAttribs = false; + if ( !empty( $options['title'] ) ) { + $attribs['title'] = $options['title']; + } } - $attribs = array( - 'alt' => $alt, - 'src' => $this->url, - ); - if ( empty( $options['no-dimensions'] ) ) { $attribs['width'] = $this->width; $attribs['height'] = $this->height; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 39129cba4c..06ac80273f 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -11095,6 +11095,15 @@ thumbsize=220 !! end +!! test +Titles in unlinked images (T23454) +!! wikitext +[[File:Foobar.jpg|link=|stuff]] +!! html/php +

stuff +

+!! end + !! test Link with empty target !! wikitext -- 2.20.1