#18984 closed defect (bug) (fixed)
Accessibility: Title attribute should not be added to image markup by media.php
Reported by: | esmi | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
Title attributes on images create issues with some assistive software (eg JAWS in verbose mode) yet are completely inaccessible to other assistive software (JAWS in non-verbose mode, VR software etc). Alt is the prescribed and 'correct' method for relaying information to non-sighted visitors or those using non-graphical browsers.
While Title is certainly needed for the media library itself, it should be removed, if possible, from the generated image markup.
Attachments (6)
Change History (51)
#2
in reply to:
↑ 1
@
13 years ago
Replying to karlgroves:
If any of these are required, it should be the alt.
No! The alt attribute should not be used for purely decorative images. As this cannot be determined by software, it must remain an author decision
I disagree with removing title from generated markup. The content author may have a valid reason for providing a title attribute.
Can you provide a reason - given that it can only be guaranteed accessible to a limited sub-set of users (ie sighted mouse users)?
#3
@
13 years ago
Using alt is indeed THE method to accessibly name images for screen readers and other assistive technologies. the title attribute is ALWAYS suplemental information that is only then referred to if alt is not available and not "". So if alt is "", title will ALWAYS be ignored. This is true for Firefox and IE support in screen readers.
#5
@
13 years ago
@esmi I'm afraid I have to disagree with your assertion that the alt attribute should not be used for purely decorative images.
When an image is presented in a web page the alt attribute should always be present. But for decorative images it should be set to an empty string - ie:
alt=""
When screen readers encounter an image without any alt attribute the screen reader is likely to read the full path and filename of the image to the user - not always meaningful or useful. Using alt="" signals to assistive technology that the image should be ignored.
Agree with you that setting of the alt attribute value should be down to the discretion of the author and judged on what the image represents or the meaning it conveys or where clicking on the image takes you.
#6
@
13 years ago
@Graham: My bad. I phrased my response poorly. Yes - of course a null alt attribute is the correct way to handle decorative images. And WordPress does handle that correctly right now. It's the enforced title attribute that's the issue here. At best, it's superfluous and annoying. At worst, it could create a barrier for some users - either by creating unwanted noise on the page or by encouraging web authors to rely on it instead of using the alt attribute appropriately.
From an educational standpoint, I think we should be trying to point web authors in the right direction with regard to the alt attribute instead of giving them the wrong crutch.
#8
follow-up:
↓ 9
@
13 years ago
- Cc travis@… added
- Keywords needs-patch added
+1 to this. The title field should be available, but not required. One problem is that WordPress uses the value of the title field for both front-end output and for organizing uploaded files on /wp-admin/media.php. Any ideas for an unambiguous way to solve that problem?
#9
in reply to:
↑ 8
;
follow-up:
↓ 11
@
13 years ago
Replying to travisnorthcutt:
One problem is that WordPress uses the value of the title field for both front-end output and for organizing uploaded files on /wp-admin/media.php.
Well, that is the rub of not requiring the title
. I suggest we continue to require the title
but not necessarily output it in markup, which is what this ticket suggests.
#11
in reply to:
↑ 9
;
follow-up:
↓ 12
@
13 years ago
Replying to DrewAPicture:
Well, that is the rub of not requiring the
title
. I suggest we continue to require thetitle
but not necessarily output it in markup, which is what this ticket suggests.
So, perhaps a "display on site" checkbox?
#12
in reply to:
↑ 11
@
13 years ago
Replying to travisnorthcutt:
So, perhaps a "display on site" checkbox?
IMHO a lot of end users would be confused at the existence of a checkbox "display title of image in HTML element on site," or however it ended up being phrased.
It sounds like the title attribute should not exist if the alt is an empty string. Perhaps a conditional editing of attributes can be employed as such:
if ( ! alt && title ) { alt = title; title = ""; }
#15
@
13 years ago
Is this not a simple fix, for the minority of users (myself included), who prefer NOT to have the title tag inserted automatically:
function remove_attachment_title_attr( $attr ) { unset($attr['title']); return $attr; } add_action('wp_get_attachment_image_attributes', 'remove_attachment_title_attr');
Definitely digging the idea of offering users the option to display or not display with a checkbox or dropdown, though I am in agreement that this would be confusing for your average Joe Schmoe end user who doesn't even know what a title tag IS...
#16
@
13 years ago
The average Joe Schmoe end user might understand "tootip". That seems to be the most common way of describing the browser rendering of title attributes amongst non-technical users.
#17
@
12 years ago
Would it not be best to explain in the form how these fields will be used by assistive technology? I think that even intermediate users may not understand how vital it is to fill out the alt field.
#19
@
12 years ago
Agreed that title is not really the preferred field to have users fill out or automate if we get to pick which field is pre-populated. Mostly because many images will then have the title "IMG_0021" or similar, which is not useful for anybody.
WP should use another way of indexing the files or rely on other meta data.
Personally I think the resolution should just be to
- Implement function to not output title fields in the actual rendered mark up (but keep it internally for indexing).
- Change Title field in Media Options to be a non-editable looking greyed out string (not textfield), with an Edit.
- Edit enables the text field, the "required field" asterisk, hides the original string, shows help about the field (editing will enable the Title HTML attribute).
- If edited, title is now output in the rendered post.
I'm a visual guy so I'll be posting a quick and dirty mockup of what this could look like shortly.
#21
@
12 years ago
- Component changed from Accessibility to Media
- Keywords needs-patch ux-feedback removed
- Milestone changed from Awaiting Review to 3.5
I know this was reported as an accessibility issue, but it's much more than that. I'm moving this to the Media component as I want to track this as one of the media 3.5 tickets.
#22
@
12 years ago
- Cc marty@… added
It sounds like the title attribute should be removed altogether and just use the "title" aspect of the image as a naming device in the back end? Why not just change title to "Name", so as we edit an image, we can give it a "Name" and edit the ALT attribute?
I'd be happy to jump on a patch for this but there doesn't seem to be a consensus about what needs to be done?
#23
@
12 years ago
"Title" is used on attachment pages as well. #21390 will result in some changes on how these fields are presented.
#24
follow-up:
↓ 25
@
12 years ago
Replying to martythornley:
It sounds like the title attribute should be removed altogether and just use the "title" aspect of the image as a naming device in the back end? Why not just change title to "Name", so as we edit an image, we can give it a "Name" and edit the ALT attribute?
I think from an administration standpoint, an image title is necessary and important and should be fed via the image's EXIF data as it is now. This is not really an issue of contention and falls outside this ticket's scope.
Really we just want to use the alt value instead of the title value in markup.
Replying to nacin:
#21390 will result in some changes on how these fields are presented
Thanks for the heads up.
#25
in reply to:
↑ 24
@
12 years ago
Replying to DrewAPicture:
Really we just want to use the alt value instead of the title value in markup.
So if that is the consensus for this ticket and leave the rest to another time, I can take a look at fixing the markup to use alt instead of title.
#26
@
12 years ago
- Keywords has-patch added
Added a patch that removes the title attribute. Looks like it was in two places, both wp_get_attachment_image() and get_image_tag(). i couldn't find it anywhere else.
#27
@
12 years ago
Looking into image captions and gallery shotcodes as well...
The following just take existing $html of an img tag and don't mess with the attributes, just wrap in the caption:
image_add_caption()
img_caption_shortcode()
Gallery shortcode uses
wp_get_attachment_link() which uses wp_get_attachment_image() which is fixed in this patch.
None of the filters surrounding these functions seem to have anything in core hooked in that would effect the title attribute.
#28
@
12 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 22409:
#30
@
12 years ago
I think a piece of [22409] was in the wrong place. get_image_tag() is a generic (if old, crufty) function and should not be touched. Its caller, get_image_send_to_editor(), should be modified.
#32
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening this again.
What we currently do is use the caption for alt if alt is empty. We should subsequently fall back to title for alt.
Many people are using titles and possibly not captions. We should not punish them.
#33
@
12 years ago
Oh. We already do this.
if ( empty($default_attr['alt']) ) $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption if ( empty($default_attr['alt']) ) $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
#35
@
12 years ago
attachment:18984.5.diff implements the fallbacks in JS instead of PHP, so strings created in JS and "from URL" output both benefit from the fallbacks as well.
If we were to go with a PHP solution, attachment:18984.4.diff needs to prevent the $title
var from being cleared before it's sent to the filter, and also ensure the title var would be sent over from the JS.
#39
@
12 years ago
So the image tooltips are missing on new images. :( Two questions:
- Is this carved in stone now?
- Since this change does nothing to old posts, does it really help assistive software users in any way?
I'm looking at my front page in RC5 and thinking, if I need to get rid of image titles for the sake of blind visitors, this hasn't accomplished that.
As a sighted webmaster, I'm concerned that the case hasn't been made for this being a WordPress bug rather than a browser bug.
#40
@
12 years ago
This is a WordPress bug. I'm sorry (but not actually sorry) that the tooltip community has felt slighted by this one, but we won't need to make a change. We made a choice, and this choice on the whole benefits all users and readers, not just those using screenreaders. How often have you moused over an image on a WordPress site and saw "IMG_1234"? One of the lamest things ever. Never again.
Tooltips can still be added by opening the Edit Image modal and inserting something into the title attribute box. The only change is that the "Title" field — which is the name of an image's attachment page — does not populate the title attribute.
#41
follow-up:
↓ 42
@
12 years ago
Just wondering when you try to add an image via "insert from URL" you get a field to enter the url and a field to enter the title. If you fill up the title then ass the url, then the title vanishes.
I though originally that it was auto saved. But true enough after inserting the image then clicking on it you see that the title field is now blank. i.e. it never saved.
Surely this is bug? If you are going to do away with titles why add a title field that doesn't save anything?
#42
in reply to:
↑ 41
@
12 years ago
Replying to TLWH:
Just wondering when you try to add an image via "insert from URL" you get a field to enter the url and a field to enter the title. If you fill up the title then ass the url, then the title vanishes.
Confirmed. This ticket was closed on a completed milestone, feel free to create a new one.
#43
@
11 years ago
This is the most stupid change i never seen, if you make the change i propose in these track there is no probleme for everyone : #22854
+1. This is enough of an annoyance that I've written a little snippet of jQuery to work around it on sites I make with Wordpress
The only required attribute here seems to be the title. If any of these are required, it should be the alt. I disagree with removing title from generated markup. The content author may have a valid reason for providing a title attribute. However, there is a potential usability problem with the way this is currently handled.
As I said above, the only field marked as required is currently the title. This may lead content authors to believe that all they need to do is provide the title (afterall, the alt isn't required). It would be preferable to have the alt be the required field here. Any logic necessary for labeling the file in the media library can come from the alt.