r50641 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50640‎ | r50641 | r50642 >
Date:19:43, 15 May 2009
Author:simetrical
Status:ok
Tags:
Comment:
(bug 16912) Tooltips on images with link= disappear

Patch based on one by Derk-Jan Hartman, which he wasn't able to commit
because he didn't have a MediaWiki installation to test on. One fix
made, and parser tests added.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MediaTransformOutput.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -3188,8 +3188,26 @@
31893189 </p>
31903190 !! end
31913191
 3192+!! test
 3193+Image with link parameter (wiki target) and unnamed parameter
 3194+!! input
 3195+[[Image:foobar.jpg|link=Target page|Title]]
 3196+!! result
 3197+<p><a href="https://www.mediawiki.org/wiki/Target_page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3198+</p>
 3199+!! end
31923200
 3201+!! test
 3202+Image with link parameter (URL target) and unnamed parameter
 3203+!! input
 3204+[[Image:foobar.jpg|link=http://example.com/|Title]]
 3205+!! result
 3206+<p><a href="http://example.com/" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3207+</p>
 3208+!! end
31933209
 3210+
 3211+
31943212 !! test
31953213 Image with frame and link
31963214 !! input
Index: trunk/phase3/includes/MediaTransformOutput.php
@@ -153,14 +153,18 @@
154154 $alt = empty( $options['alt'] ) ? '' : $options['alt'];
155155 # Note: if title is empty and alt is not, make the title empty, don't
156156 # use alt; only use alt if title is not set
157 - $title = !isset( $options['title'] ) ? $alt : $options['title'];
 157+ $title = !isset( $options['title'] ) ? $alt : $options['title'];
158158 $query = empty($options['desc-query']) ? '' : $options['desc-query'];
159159
160160 if ( !empty( $options['custom-url-link'] ) ) {
161161 $linkAttribs = array( 'href' => $options['custom-url-link'] );
 162+ if ( $alt ) {
 163+ $linkAttribs['title'] = $alt;
 164+ }
162165 } elseif ( !empty( $options['custom-title-link'] ) ) {
163166 $title = $options['custom-title-link'];
164 - $linkAttribs = array( 'href' => $title->getLinkUrl(), 'title' => $title->getFullText() );
 167+ $linkAttribs = array( 'href' => $title->getLinkUrl(),
 168+ 'title' => empty( $options['alt'] ) ? $title->getFullText() : $alt );
165169 } elseif ( !empty( $options['desc-link'] ) ) {
166170 $linkAttribs = $this->getDescLinkAttribs( $title, $query );
167171 } elseif ( !empty( $options['file-link'] ) ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -121,6 +121,7 @@
122122 tweaked spacing.
123123 * (bug 18656) Use proper directory separators in wfMkdirParents()
124124 * (bug 18549) Make Special:Blockip respect $wgEnableUserEmail and $wgSysopEmailBans
 125+* (bug 16912) Tooltips on images with link= disappear
125126
126127 == API changes in 1.16 ==
127128

Status & tagging log