[wp-trac] [WordPress Trac] #41147: Alternative Text Issue
WordPress Trac
noreply at wordpress.org
Sat Jun 24 15:17:36 UTC 2017
#41147: Alternative Text Issue
--------------------------+------------------------------
Reporter: BNOTP | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 4.7
Severity: normal | Resolution:
Keywords: close | Focuses: accessibility
--------------------------+------------------------------
Comment (by adamsilverstein):
Replying to [comment:2 BNOTP]:
> So sad that those making these decisions don't get input from blogs of
all types before making such important changes.
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 [https://wordpress.org/about/philosophy/ 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 `function.php` file:
{{{
#!php
/**
* 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' );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41147#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list