0

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

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.