Last modified: 2014-06-01 12:43:30 UTC
Using the new parser, using [[Image:some.png|<nowiki/>]] does not work anymore, i.e. it produces an alt text of "some.png", when it should be empty. http://spiele.j-crew.de/wiki/SpieleWiki:Test demonstrates the problem (the site was updated from SVN a few days ago). I cannot reproduce this on Wikipedia sites; I think it works there because Wikipedia is still using the old parser.
I have to correct myself: It doesn't seem to be a bug of the new parser (at least I can now reproduce it using the old parser) and the alt text is in fact correct. The problem is that the surrounding link has a 'title' attribute, so the HTML produced for [[Image:some.png|<nowiki/>]] is <a href="/wiki/Image:Some.png" class="image" title="Some.png"><img alt="" src="some path" width="474" height="466" border="0" /></a> when it should be <a href="/wiki/Image:Some.png" class="image" title=""><img alt="" src="some path" width="474" height="466" border="0" /></a> leading to a tooltip with "Some.png" in it when hovering over the image (at least in Firefox and Konqueror). I still think this is a bug, but at least it should not affect screen readers and the like, so I'm reducing the severity.
Proposed patch: --- includes/MediaTransformOutput.php (Revision 29164) +++ includes/MediaTransformOutput.php (Arbeitskopie) @@ -76,10 +76,6 @@ function getDescLinkAttribs( $alt = false ) { $query = $this->page ? ( 'page=' . urlencode( $this->page ) ) : ''; - $title = $this->file->getTitle(); - if ( strval( $alt ) === '' ) { - $alt = $title->getText(); - } return array( 'href' => $this->file->getTitle()->getLocalURL( $query ), 'class' => 'image', Sidenote: Looking through the parser tests, I saw that [[Image:Some.png]] has an alt-text, while [[Image:Some.png|right]] doesn't have one. I think that's a bug, too, but a very low priority one.
Thomas, can you check whether your proposed patch works against current trunk, and attach it to this bug as a diff? Thanks!
I'm sorry, but I don't currently have any time for MediaWiki development. So if someone else could check this, it would be great :)
Patch no longer works against trunk, however I'll take a look at fixing the bug.
But isn't a file name better than an empty alt="" tag? I think that the current behavior is more desirable. Is there a case where you feel it isn't?
Some images are purely for decoration, they should not produce any text in a screenreader or text-only browser. As a random example, look at the headings in http://spiele.j-crew.de/wiki/Die_Wasserzwerge . On that wiki, there are standardized headings, each containing an image on the left, to make the sections stand out. But a screenreader should completely ignore these images. I think MediaWiki should provide a syntax to achieve this. It used to work by adding <nowiki/> as the title, like this: [[Image:some.png|<nowiki/>]]
Doesn't [[Image:some.png|alt=]] do what you want?
I cannot reproduce the problem on MediaWiki 1.22 anymore. So apparently the bug has been fixed in the meantime.