Index: trunk/phase3/HISTORY |
— | — | @@ -134,6 +134,10 @@ |
135 | 135 | on a different database |
136 | 136 | * Add a class if 'missingsummary' is triggered to allow styling of the summary |
137 | 137 | line |
| 138 | +* Title attributes are now always blank on framed and thumbnailed images, and default to blank |
| 139 | + on inline images instead of defaulting to the image's filename. Additionally, the alt |
| 140 | + attribute now defaults to the filename on framed and thumbnailed images if no caption or alt |
| 141 | + attribute is specified. |
138 | 142 | |
139 | 143 | === Bug fixes in 1.15 === |
140 | 144 | * (bug 16968) Special:Upload no longer throws useless warnings. |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1582,29 +1582,29 @@ |
1583 | 1583 | # Don't allow internal links to pages containing |
1584 | 1584 | # PROTO: where PROTO is a valid URL protocol; these |
1585 | 1585 | # should be external links. |
1586 | | - if (preg_match('/^\b(?:' . wfUrlProtocols() . ')/', $m[1])) { |
| 1586 | + if ( preg_match( '/^\b(?:' . wfUrlProtocols() . ')/', $m[1] ) ) { |
1587 | 1587 | $s .= $prefix . '[[' . $line ; |
1588 | 1588 | wfProfileOut( __METHOD__."-misc" ); |
1589 | 1589 | continue; |
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | # Make subpage if necessary |
1593 | | - if( $useSubpages ) { |
| 1593 | + if ( $useSubpages ) { |
1594 | 1594 | $link = $this->maybeDoSubpageLink( $m[1], $text ); |
1595 | 1595 | } else { |
1596 | 1596 | $link = $m[1]; |
1597 | 1597 | } |
1598 | 1598 | |
1599 | | - $noforce = (substr($m[1], 0, 1) !== ':'); |
| 1599 | + $noforce = (substr( $m[1], 0, 1 ) !== ':'); |
1600 | 1600 | if (!$noforce) { |
1601 | 1601 | # Strip off leading ':' |
1602 | | - $link = substr($link, 1); |
| 1602 | + $link = substr( $link, 1 ); |
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | wfProfileOut( __METHOD__."-misc" ); |
1606 | 1606 | wfProfileIn( __METHOD__."-title" ); |
1607 | | - $nt = Title::newFromText( $this->mStripState->unstripNoWiki($link) ); |
1608 | | - if( $nt === NULL ) { |
| 1607 | + $nt = Title::newFromText( $this->mStripState->unstripNoWiki( $link ) ); |
| 1608 | + if ( $nt === NULL ) { |
1609 | 1609 | $s .= $prefix . '[[' . $line; |
1610 | 1610 | wfProfileOut( __METHOD__."-title" ); |
1611 | 1611 | continue; |
— | — | @@ -1614,9 +1614,9 @@ |
1615 | 1615 | $iw = $nt->getInterWiki(); |
1616 | 1616 | wfProfileOut( __METHOD__."-title" ); |
1617 | 1617 | |
1618 | | - if ($might_be_img) { # if this is actually an invalid link |
| 1618 | + if ( $might_be_img ) { # if this is actually an invalid link |
1619 | 1619 | wfProfileIn( __METHOD__."-might_be_img" ); |
1620 | | - if ($ns == NS_FILE && $noforce) { #but might be an image |
| 1620 | + if ( $ns == NS_FILE && $noforce ) { #but might be an image |
1621 | 1621 | $found = false; |
1622 | 1622 | while ( true ) { |
1623 | 1623 | #look at the next 'line' to see if we can close it there |
— | — | @@ -1660,14 +1660,14 @@ |
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | $wasblank = ( '' == $text ); |
1664 | | - if( $wasblank ) $text = $link; |
| 1664 | + if ( $wasblank ) $text = $link; |
1665 | 1665 | |
1666 | 1666 | # Link not escaped by : , create the various objects |
1667 | | - if( $noforce ) { |
| 1667 | + if ( $noforce ) { |
1668 | 1668 | |
1669 | 1669 | # Interwikis |
1670 | 1670 | wfProfileIn( __METHOD__."-interwiki" ); |
1671 | | - if( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) { |
| 1671 | + if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) { |
1672 | 1672 | $this->mOutput->addLanguageLink( $nt->getFullText() ); |
1673 | 1673 | $s = rtrim($s . $prefix); |
1674 | 1674 | $s .= trim($trail, "\n") == '' ? '': $prefix . $trail; |
— | — | @@ -1679,12 +1679,19 @@ |
1680 | 1680 | if ( $ns == NS_FILE ) { |
1681 | 1681 | wfProfileIn( __METHOD__."-image" ); |
1682 | 1682 | if ( !wfIsBadImage( $nt->getDBkey(), $this->mTitle ) ) { |
1683 | | - # recursively parse links inside the image caption |
1684 | | - # actually, this will parse them in any other parameters, too, |
1685 | | - # but it might be hard to fix that, and it doesn't matter ATM |
1686 | | - $text = $this->replaceExternalLinks($text); |
1687 | | - $holders->merge( $this->replaceInternalLinks2( $text ) ); |
1688 | | - |
| 1683 | + if ( $wasblank ) { |
| 1684 | + # if no parameters were passed, $text |
| 1685 | + # becomes something like "File:Foo.png", |
| 1686 | + # which we don't want to pass on to the |
| 1687 | + # image generator |
| 1688 | + $text = ''; |
| 1689 | + } else { |
| 1690 | + # recursively parse links inside the image caption |
| 1691 | + # actually, this will parse them in any other parameters, too, |
| 1692 | + # but it might be hard to fix that, and it doesn't matter ATM |
| 1693 | + $text = $this->replaceExternalLinks($text); |
| 1694 | + $holders->merge( $this->replaceInternalLinks2( $text ) ); |
| 1695 | + } |
1689 | 1696 | # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them |
1690 | 1697 | $s .= $prefix . $this->armorLinks( $this->makeImage( $nt, $text, $holders ) ) . $trail; |
1691 | 1698 | } |
— | — | @@ -4375,7 +4382,8 @@ |
4376 | 4383 | # * none same, but not aligned |
4377 | 4384 | # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox |
4378 | 4385 | # * center center the image |
4379 | | - # * framed Keep original image size, no magnify-button. |
| 4386 | + # * frame Keep original image size, no magnify-button. |
| 4387 | + # * framed Same as "frame" |
4380 | 4388 | # * frameless like 'thumb' but without a frame. Keeps user preferences for width |
4381 | 4389 | # * upright reduce width for upright images, rounded to full __0 px |
4382 | 4390 | # * border draw a 1px border around the image |
— | — | @@ -4515,7 +4523,11 @@ |
4516 | 4524 | |
4517 | 4525 | $params['frame']['caption'] = $caption; |
4518 | 4526 | |
4519 | | - $params['frame']['title'] = $this->stripAltText( $caption, $holders ); |
| 4527 | + # Will the image be presented in a frame, with the caption below? |
| 4528 | + $imageIsFramed = isset( $params['frame']['frame'] ) || |
| 4529 | + isset( $params['frame']['framed'] ) || |
| 4530 | + isset( $params['frame']['thumbnail'] ) || |
| 4531 | + isset( $params['frame']['manualthumb'] ); |
4520 | 4532 | |
4521 | 4533 | # In the old days, [[Image:Foo|text...]] would set alt text. Later it |
4522 | 4534 | # came to also set the caption, ordinary text after the image -- which |
— | — | @@ -4533,11 +4545,27 @@ |
4534 | 4546 | # named parameter entirely for images without a caption; adding an ex- |
4535 | 4547 | # plicit caption= parameter and preserving the old magic unnamed para- |
4536 | 4548 | # meter for BC; ... |
4537 | | - if( $caption !== '' && !isset( $params['frame']['alt'] ) |
4538 | | - && !isset( $params['frame']['framed'] ) |
4539 | | - && !isset( $params['frame']['thumbnail'] ) |
4540 | | - && !isset( $params['frame']['manualthumb'] ) ) { |
4541 | | - $params['frame']['alt'] = $params['frame']['title']; |
| 4549 | + if ( $imageIsFramed ) { # Framed image |
| 4550 | + if ( $caption === '' && !isset( $params['frame']['alt'] ) ) { |
| 4551 | + # No caption or alt text, add the filename as the alt text so |
| 4552 | + # that screen readers at least get some description of the image |
| 4553 | + $params['frame']['alt'] = $title->getText(); |
| 4554 | + } |
| 4555 | + # Do not set $params['frame']['title'] because tooltips don't make sense |
| 4556 | + # for framed images |
| 4557 | + } else { # Inline image |
| 4558 | + if ( !isset( $params['frame']['alt'] ) ) { |
| 4559 | + # No alt text, use the "caption" for the alt text |
| 4560 | + if ( $caption !== '') { |
| 4561 | + $params['frame']['alt'] = $this->stripAltText( $caption, $holders ); |
| 4562 | + } else { |
| 4563 | + # No caption, fall back to using the filename for the |
| 4564 | + # alt text |
| 4565 | + $params['frame']['alt'] = $title->getText(); |
| 4566 | + } |
| 4567 | + } |
| 4568 | + # Use the "caption" for the tooltip text |
| 4569 | + $params['frame']['title'] = $this->stripAltText( $caption, $holders ); |
4542 | 4570 | } |
4543 | 4571 | |
4544 | 4572 | wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) ); |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -447,8 +447,7 @@ |
448 | 448 | $page = isset( $hp['page'] ) ? $hp['page'] : false; |
449 | 449 | if ( !isset( $fp['align'] ) ) $fp['align'] = ''; |
450 | 450 | if ( !isset( $fp['alt'] ) ) $fp['alt'] = ''; |
451 | | - # Backward compatibility, title used to always be equal to alt text |
452 | | - if ( !isset( $fp['title'] ) ) $fp['title'] = $fp['alt']; |
| 451 | + if ( !isset( $fp['title'] ) ) $fp['title'] = ''; |
453 | 452 | |
454 | 453 | $prefix = $postfix = ''; |
455 | 454 | |
— | — | @@ -566,8 +565,7 @@ |
567 | 566 | $page = isset( $hp['page'] ) ? $hp['page'] : false; |
568 | 567 | if ( !isset( $fp['align'] ) ) $fp['align'] = 'right'; |
569 | 568 | if ( !isset( $fp['alt'] ) ) $fp['alt'] = ''; |
570 | | - # Backward compatibility, title used to always be equal to alt text |
571 | | - if ( !isset( $fp['title'] ) ) $fp['title'] = $fp['alt']; |
| 569 | + if ( !isset( $fp['title'] ) ) $fp['title'] = ''; |
572 | 570 | if ( !isset( $fp['caption'] ) ) $fp['caption'] = ''; |
573 | 571 | |
574 | 572 | if ( empty( $hp['width'] ) ) { |
Index: trunk/phase3/includes/MediaTransformOutput.php |
— | — | @@ -86,9 +86,6 @@ |
87 | 87 | $query .= $query ? '&'.$params : $params; |
88 | 88 | } |
89 | 89 | $title = $this->file->getTitle(); |
90 | | - if ( strval( $alt ) === '' ) { |
91 | | - $alt = $title->getText(); |
92 | | - } |
93 | 90 | return array( |
94 | 91 | 'href' => $this->file->getTitle()->getLocalURL( $query ), |
95 | 92 | 'class' => 'image', |
— | — | @@ -164,7 +161,7 @@ |
165 | 162 | } elseif ( !empty( $options['custom-title-link'] ) ) { |
166 | 163 | $title = $options['custom-title-link']; |
167 | 164 | $linkAttribs = array( 'href' => $title->getLinkUrl(), |
168 | | - 'title' => empty( $options['alt'] ) ? $title->getFullText() : $alt ); |
| 165 | + 'title' => $alt ); |
169 | 166 | } elseif ( !empty( $options['desc-link'] ) ) { |
170 | 167 | $linkAttribs = $this->getDescLinkAttribs( $title, $query ); |
171 | 168 | } elseif ( !empty( $options['file-link'] ) ) { |