jenkins-bot has submitted this change and it was merged.

Change subject: Always set a title on images when provided
......................................................................


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
---
M includes/media/MediaTransformOutput.php
M tests/parser/parserTests.txt
2 files changed, 17 insertions(+), 5 deletions(-)

Approvals:
  Cscott: Looks good to me, approved
  Bartosz Dziewoński: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/media/MediaTransformOutput.php 
b/includes/media/MediaTransformOutput.php
index d9327fb..304cc03 100644
--- a/includes/media/MediaTransformOutput.php
+++ b/includes/media/MediaTransformOutput.php
@@ -352,6 +352,11 @@
 
                $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,12 +386,10 @@
                        $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;
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 39129cb..06ac802 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -11096,6 +11096,15 @@
 !! end
 
 !! test
+Titles in unlinked images (T23454)
+!! wikitext
+[[File:Foobar.jpg|link=|stuff]]
+!! html/php
+<p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg"; 
title="stuff" width="1941" height="220" />
+</p>
+!! end
+
+!! test
 Link with empty target
 !! wikitext
 [[]]

-- 
To view, visit https://gerrit.wikimedia.org/r/153353
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6302246cf28c84ade805a6a7d4a5e131b6f42e86
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to