Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -3289,7 +3289,14 @@ |
3290 | 3290 | </p> |
3291 | 3291 | !! end |
3292 | 3292 | |
| 3293 | +!! test |
| 3294 | +Thumbnail image with link parameter |
| 3295 | +!! input |
| 3296 | +[[Image:foobar.jpg|thumb|link=http://example.com/|Title]] |
| 3297 | +!! result |
| 3298 | +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> |
3293 | 3299 | |
| 3300 | +!! end |
3294 | 3301 | |
3295 | 3302 | !! test |
3296 | 3303 | Image with frame and link |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -529,16 +529,7 @@ |
530 | 530 | 'title' => $fp['title'], |
531 | 531 | 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false , |
532 | 532 | 'img-class' => isset( $fp['border'] ) ? 'thumbborder' : false ); |
533 | | - if ( !empty( $fp['link-url'] ) ) { |
534 | | - $params['custom-url-link'] = $fp['link-url']; |
535 | | - } elseif ( !empty( $fp['link-title'] ) ) { |
536 | | - $params['custom-title-link'] = $fp['link-title']; |
537 | | - } elseif ( !empty( $fp['no-link'] ) ) { |
538 | | - // No link |
539 | | - } else { |
540 | | - $params['desc-link'] = true; |
541 | | - $params['desc-query'] = $query; |
542 | | - } |
| 533 | + $params = $this->getImageLinkMTOParams( $fp, $query ) + $params; |
543 | 534 | |
544 | 535 | $s = $thumb->toHtml( $params ); |
545 | 536 | } |
— | — | @@ -549,6 +540,27 @@ |
550 | 541 | } |
551 | 542 | |
552 | 543 | /** |
| 544 | + * Get the link parameters for MediaTransformOutput::toHtml() from given |
| 545 | + * frame parameters supplied by the Parser. |
| 546 | + * @param $frameParams The frame parameters |
| 547 | + * @param $query An optional query string to add to description page links |
| 548 | + */ |
| 549 | + function getImageLinkMTOParams( $frameParams, $query = '' ) { |
| 550 | + $mtoParams = array(); |
| 551 | + if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) { |
| 552 | + $mtoParams['custom-url-link'] = $frameParams['link-url']; |
| 553 | + } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) { |
| 554 | + $mtoParams['custom-title-link'] = $frameParams['link-title']; |
| 555 | + } elseif ( !empty( $frameParams['no-link'] ) ) { |
| 556 | + // No link |
| 557 | + } else { |
| 558 | + $mtoParams['desc-link'] = true; |
| 559 | + $mtoParams['desc-query'] = $query; |
| 560 | + } |
| 561 | + return $mtoParams; |
| 562 | + } |
| 563 | + |
| 564 | + /** |
553 | 565 | * Make HTML for a thumbnail including image, border and caption |
554 | 566 | * @param $title Title object |
555 | 567 | * @param $file File object or false if it doesn't exist |
— | — | @@ -632,32 +644,31 @@ |
633 | 645 | $url = wfAppendQuery( $url, 'page=' . urlencode( $page ) ); |
634 | 646 | } |
635 | 647 | |
636 | | - $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) ); |
637 | | - |
638 | 648 | $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">"; |
639 | 649 | if( !$exists ) { |
640 | 650 | $s .= $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time==true ); |
641 | | - $zoomicon = ''; |
| 651 | + $zoomIcon = ''; |
642 | 652 | } elseif ( !$thumb ) { |
643 | 653 | $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) ); |
644 | | - $zoomicon = ''; |
| 654 | + $zoomIcon = ''; |
645 | 655 | } else { |
646 | | - $s .= $thumb->toHtml( array( |
| 656 | + $params = array( |
647 | 657 | 'alt' => $fp['alt'], |
648 | 658 | 'title' => $fp['title'], |
649 | | - 'img-class' => 'thumbimage', |
650 | | - 'desc-link' => true, |
651 | | - 'desc-query' => $query ) ); |
| 659 | + 'img-class' => 'thumbimage' ); |
| 660 | + $params = $this->getImageLinkMTOParams( $fp, $query ) + $params; |
| 661 | + $s .= $thumb->toHtml( $params ); |
652 | 662 | if ( isset( $fp['framed'] ) ) { |
653 | | - $zoomicon=""; |
| 663 | + $zoomIcon = ""; |
654 | 664 | } else { |
655 | | - $zoomicon = '<div class="magnify">'. |
656 | | - '<a href="'.$url.'" class="internal" title="'.$more.'">'. |
657 | | - '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' . |
658 | | - 'width="15" height="11" alt="" /></a></div>'; |
| 665 | + $zoomIcon = '<div class="magnify">'. |
| 666 | + '<a href="' . htmlspecialchars( $url ) . '" class="internal" ' . |
| 667 | + 'title="' . htmlspecialchars( wfMsg( 'thumbnail-more' ) ) . '">'. |
| 668 | + '<img src="' . htmlspecialchars( $wgStylePath ) . '/common/images/magnify-clip.png" ' . |
| 669 | + 'width="15" height="11" alt="" /></a></div>'; |
659 | 670 | } |
660 | 671 | } |
661 | | - $s .= ' <div class="thumbcaption">'.$zoomicon.$fp['caption']."</div></div></div>"; |
| 672 | + $s .= ' <div class="thumbcaption">' . $zoomIcon . $fp['caption'] . "</div></div></div>"; |
662 | 673 | return str_replace("\n", ' ', $s); |
663 | 674 | } |
664 | 675 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -281,7 +281,8 @@ |
282 | 282 | to the local alias. |
283 | 283 | * (bug 24296) Added converttitles parameter to convert titles to their |
284 | 284 | canonical language variant. |
285 | | - |
| 285 | +* Fixed "link" parameter in image links with "thumb" parameter. |
| 286 | + |
286 | 287 | === Languages updated in 1.17 === |
287 | 288 | |
288 | 289 | MediaWiki supports over 330 languages. Many localisations are updated |