I have decoration image in my website.
They don't have an alt attribute value because I don't want that the screen reader are disturbing by decoration images.
But wordpress put just the word alt without the proper syntax.
I need to replace the alt word by alt="".
I tried that filter, but it doesn't change anything in my source code.
add_filter('wp_get_attachment_image_attributes', function($attr) {
if (!isset($attr['alt']) || trim($attr['alt']) === '') {
$attr['alt'] = '';
}
return $attr;
}, 10, 1);
Could you help me to fix it ? Thanks Caroline
altandalt=""are the same thing, see The HTML syntax | Attributes under Empty attribute syntax: "Just the attribute name. The value is implicitly the empty string."