WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#41147 closed defect (bug) (invalid)

Alternative Text Issue

Reported by: BNOTP Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Media Keywords: close
Focuses: accessibility Cc:

Description

I absolutely hate that the Alternative Text box doesn't fill in with the title. I just realized this so I have a tons and tons of photos in posts now without Alt Text. It always filled in before which was excellent since I've name my images correctly.
If you're going to ruin a great feature for those who liked it, why don't you at least create a setting that gives us a choice how we want it to work when we upload a photo.
It's ridiculous to have to do double the work by having to name all our images twice.
Sometimes I wonder if anyone at Wordpress even talks to Bloggers/site users before making changes! I could cry for all the lost SEO opportunities and extra work that'sI am now facing.

Change History (4)

#1 @afercia
3 years ago

  • Component changed from General to Media
  • Focuses accessibility added
  • Keywords close added
  • Version changed from 4.8 to 4.7

@BNOTP welcome to Trac and thanks for your feedback.

since I've name my images correctly.

That's exactly the point. Not all users do that. I'd say the vast majority of users don't. Having images end up with an alt attribute corresponding to their file name, for example something like DSC_784345374, it's something that should be definitely avoided. For this reason the fallback that used to set the alt attribute to the image title was recently changed, that was an intentional, broadly discussed, and conscious decision. See the related ticket for more details: #34635

ideally, setting the image alt attribute should always be made on a case by case basis. In most of the cases, images are purely decorative and they just need an empty alt attribute. When they convey relevant information instead, they need a meaningful alt attribute that often depends on the context the image is going to be used in. From this perspective, asking users to explicitly set an alt attribute text as a result of a careful thought is highly preferable.

I'd also like to remind all WordPress development happens publicly, and everybody has the opportunity to follow, participate, contribute, and discuss. Also, using a polite language could help your voice being heard.

#2 follow-up: @BNOTP
3 years ago

Again, why not make a setting where publishers can decide if they want it to auto-fill or not, rather than make a significant decision like that for everyone. For DIY, Decorating, Fashion, Photography, Travel, Gardening blogs (and many more, I suspect) images are not "purely decorative," they are critical to the post. Our future readers often search via images. So sad that those making these decisions don't get input from blogs of all types before making such important changes.
I was up until 5 AM going back through posts and have barely made a dent. I blog 4 times a week and use a ton of photos. Unfortunately, it appears when I add alt text to the image in the "Media" section of my blog, it does not add it to image in the post. So it appears I have double the work to do to try and fix all my images now, is that right?
I'll have to go back and add it to every image in every post dating back to when the change occurred AND I will need to add it to every image in the Media section so when I use that image again in the future, the information will be there.
I guess I will start with the posts, but will the Google bots recrawl those posts at some point and find my images?

Susan

#3 in reply to: ↑ 2 @adamsilverstein
3 years ago

Replying to BNOTP:

So sad that those making these decisions don't get input from blogs of all types before making such important changes.

@BNOTP/Susan,

That is absolutely not the case and if you read the ticket @afercia referenced you will see the wide-ranging discussion. Your accusatory tone is disheartening and unfair to the many volunteers who work so hard to bring you the free software you use to run your site.

The reason you don't see an option to change this behavior in the admin is that one of the core WordPress philosophies is "Decisions not Options." This change was a well-reasoned, careful and deliberate decision that improves the software for the vast majority of users.

That said, we are deeply committed to extensibility, and allowing users and developers to meld the software to suit their needs. We do this in part by providing code hooks that can change nearly every part of WordPress.

In your case, the following code snippet should restore the behavior you desire (warning - I wrote this up quickly and without testing, so make sure you test it out locally before running on your live site - let me know if it doesn't work as expected).

This code should be added to your theme's functions.php file:

/**
 * Filter the image tag html, setting the alt attribute to the image title.
 */
function my_filter_the_image_tag( $html, $id, $alt, $title, $align, $size ) {
        list( $img_src, $width, $height ) = image_downsize( $id, $size );
        $hwstring = image_hwstring( $width, $height );
        $class = 'align' . esc_attr( $align ) .' size-' . esc_attr( $size ) . ' wp-image-' . $id;

        return '<img src="' . esc_attr( $img_src ) . '" alt="' . esc_attr( $title ) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
}
add_filter( 'get_image_tag', 'my_filter_the_image_tag' );
Last edited 3 years ago by adamsilverstein (previous) (diff)

#4 @adamsilverstein
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.