For accessibility reasons, meaningful images should have alt text.
theme_file_icon() adds empty alt text.
While the image is meaningful in that it conveys a file type, it could also be argued that because the screen reader can read the file name the user could determine the file type anyway.
So, should we have alt text or not?
Personally I don't see the harm in having alt text for these images, however I'm not someone who ouses screen readers so for all I know it might be annoying to have potentially redundant information.
Comment | File | Size | Author |
---|---|---|---|
#21 | drupal-icon_alt-1507754-21.patch | 2.15 KB | h3rj4n |
#20 | drupal-icon_alt-1507754-20.patch | 2.95 KB | h3rj4n |
#11 | title_to_img-1507754-test.patch | 1.11 KB | plopesc |
#11 | title_to_img-1507754-combined.patch | 1.81 KB | plopesc |
#9 | drupal-add_title_tag_to_img-1507754-7.patch-before.png | 69.16 KB | andymartha |
Comments
Comment #1
rooby CreditAttribution: rooby commentedI'm actually leaning towards it being redundant and therefore unwanted. But agreeance from someone else would be good too.
Comment #2
rooby CreditAttribution: rooby commentedHowever in that case the image should also have empty or no title attribute.
Comment #3
Everett Zufelt CreditAttribution: Everett Zufelt commentedHow does Drupal decide which icon to display, is it based on file extension? If so, I would argue that the alt text on the image is redundant (provided that the file name is always available in the link text, and that the alt text on the image should be null, e.g. "".
Otherwise, if the image and the file extension available to the user are not always the exact same thing, then the alt text on the image should be provided. At which time I'd love a list of images and a brief description of each so that we can determine the best alt text.
Comment #4
rooby CreditAttribution: rooby commentedThe icon is determined by the file mime type.
However now that you mention it, the theme function can be used anywhere, so there is no guarantee it will be displayed with the file name, or anything else that might describe the file type or make the image description redundant.
So it seems like alt text would be the way to go.
Ideally it would be something generated automatically from the mime type.
Maybe something along the lines of?:
Comment #5
Everett Zufelt CreditAttribution: Everett Zufelt commentedCan you please provide a few example mimetype strings?
Comment #6
rooby CreditAttribution: rooby commentedaudio/mp4
audio/mpeg
image/jpeg
image/png
application/pdf
text/plain
text/csv
For more see http://en.wikipedia.org/wiki/MIME_type#List_of_common_media_types
Actually on second check (forgive my mistake, it's late), it isn't directly using mime type. It uses it in a round about way.
Some icon file names directly relate to the mime type (like pdf, plain text, html text), some use generic icons (all audio types are the same, video are the same etc), some are manually mapped via file_icon_map() (like ms office docs etc.) and application-octet-stream.png is a fallback icon.
So either we have an equally elaborate method of working out the alt text or it could potentially be based on the file name of the icon minus the extension or else based on the unaltered mime type like the title text is currently (it is just the mime type by itself).
Curse these tiny accessibility issues.
Comment #7
johnvcoming from #1369616: file field formatters: also for images + new formatter 'mime-icon only', which asks for an mime-icon-only formatter, with filename in the alt-text.
The following shows the complete filename as alt-text.
Comment #8
h3rj4n CreditAttribution: h3rj4n commentedI created a patch as suggested in comment #7. While I was creating the patch I figured that the origname doesn't exists? It isn't in the documentation on this page. Changed it to the filename. I'm not sure if that's the best way.
Any other solutions I can think of need extra variables to be passed on to the them function. That's also the case in patch #1369616: file field formatters: also for images + new formatter 'mime-icon only' comment 6.
Comment #9
andymartha CreditAttribution: andymartha commentedI can confirm that the patch in #8 changes the file icon image title in uploaded files from "image/jpeg" to "filename.jpg" without breaking anything in Drupal 8.x-dev. See attached images of before and after the patch.
Good job, but not sure if it closes the issue.
Comment #10
tim.plunkettThis should have automated tests.
Comment #11
plopescHello
I'm working on this issue as part of core mentoring hours (http://core.drupalofficehours.org/task/1897).
I don't know if tests for this issue should test the file name in
theme_file_icon()
or test the wholetheme_file_link()
process, including the icon name generation, the link itself, etc.I'm proposing a first approach.
Please give me feedback.
Regards
Comment #12
h3rj4n CreditAttribution: h3rj4n commentedI think you have to set the status of this issue to needs review before it will be tested.
Comment #13
rooby CreditAttribution: rooby commentedI think I prefer the approach in #1369616-6: file field formatters: also for images + new formatter 'mime-icon only', where you can pass in the title if you would like to. However, I also think that if no title is passed in that the title should be an empty string.
Like so:
I really can't see people wanting to see the mime type of a document, it's gibberish to most people.
Also, it really doesn't add any value. The icon is almost always positioned next to text containing the file name, and if not people can pass their own title value in.
Another thing to be careful of is having an image with meaning, with no alt text, but with meaningful title text. This is generally an accessibility no-no.
Meaningful images should have meaningful alt text, but don't really need meaningful title text.
Title text is not necessarily read by screen readers and is not a replacement for alt text.
If the title text is not really that valuable and it wouldn't matter to a screen reader user if they didn't read the title text, then it is more of a grey area, in which case do we really need title text at all?
Isn't no title text better than gibberish title text?
Comment #14
loopy1492 CreditAttribution: loopy1492 commentedSubscribing.
Is there a way to tell if this bug is being worked on for 7.x as well?
Comment #15
rooby CreditAttribution: rooby commented@loopy1492:
The bug will be fixed in drupal 8 first, then backported to drupal 7 in this same issue.
At any stage, if someone wants to they can create a drupal 7 version of the patch and post it here for people to use on drupal 7 in the meantime.
In that case the patch file should be named so that the test bot skips it. Otherwise it will try to patch drupal 8 with a drupal 7 patch and fail. See https://drupal.org/node/332678#skipping for more information.
Comment #16
pandaPowder CreditAttribution: pandaPowder commentedIt sounds like you already have a direction chosen based on the patches submitted, but my opinion is that any image that conveys information should have that same information conveyed in the alt text. Decorative only images should have alt=""
File type icons certainly convey information beyond what might be displayed in the text of the link. The text of the link might be a descriptor for the file, or it might be the filename. I think most clients/slighted users would prefer a descriptor. Therefore, the icon itself is mainly responsible for conveying the file type. Therefore, we should set the alt text based on the mime type.
In the case of direct mappings, this would be great to let screen reader users know what they're clicking on. In the case of fallbacks and generic audio files, the alt text should be as generic as the file type icon. A generic file type icon conveys a certain amount of information to the sighted user (such as audio or video to use your example) which is the same information that should be conveyed in the alt text.
for reference:
http://webaim.org/techniques/alttext/
Comment #17
mgiffordTagging.
Also, for reference https://drupal.org/node/465106#alt-text
Comment #18
mgifford#11: title_to_img-1507754-combined.patch queued for re-testing.
Comment #20
h3rj4n CreditAttribution: h3rj4n commentedI rerolled the patch. Also set the alt text to the mime type because of comment #16.
I wasn't able to create a interdiff.
Comment #21
h3rj4n CreditAttribution: h3rj4n commentedPrevious one was a merge commit / diff. I'm not sure if the test bot is able to apply that one. This one should be the good one.
Comment #23
mgifford21: drupal-icon_alt-1507754-21.patch queued for re-testing.
Comment #24
mgiffordWe've got a duplicate here #2163209: Add alternate text to file icon
Comment #26
johnvOK, let's use the new tools to link issues.
Comment #27
Charles BelovI'm sorry I missed this issue when I created #2163209: Add alternate text to file icon. It appears I've created a duplicate.
As to the comment whether this icon is purely decorative, that question seems to revolve on the fact that in a list of files, the file extension is seen. However:
1) If the file is inserted into Body text, the file name may be replaced with text describing the content. Therefore, an extension might not be shown and the icon would definitely not be docorative.
2) Operating systems often hide the extension by default, not on the web page but on the computer; therefore website visitors may not be sensitized to the existence of file extensions and the presence of extensions on a website might even be mysterious to them. (It would, however, be a separate issue as to whether to hide the file extension in a file list and just rely on the file type icon.)
As I stated in #2163209, I agree that MIME types are gibberish to most website visitors and do not belong in either the alt text or the title text.
Comment #28
mgiffordMarking this one as a duplicate. Mostly because the mime type isn't a good alt text and the other issue is addressing that.