John Davidson

php - Add alt text for missing alt images for whole website

0 comments
Message:


I would like to add alt text for missing alt of all images in my wordpress website. I found the following code and added to my function.php. It not work. So could you please check for me what I need to do?
Thanks


function add_alt_to_images_if_missing( $attr, $attachment = null ) {
if($attr['alt']==''){
$attr['alt']=trim( strip_tags( $attachment->post_title ) );
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes','add_alt_to_images_if_missing', 10, 2 );


My Answer:
>post_title ) );_}_return $attr;_}_add_filter( 'wp_get_attachment_image_attributes', 'add_alt_to_images_if_missing', 10, 2 );

Rate this post

3 of 5 based on 9538 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us