How to Add Missing Alt Tags To WordPress Images
Images are important for engagement with your visitors but the problem with images is that they mean nothing to search engines. The only way search engines can tell what an image is about is by reading the information inside the alt attribute. Below is a WordPress snippet to put into your functions.php file to search your content for images which don’t have an alt attribute. If they don’t have an alt attribute this function will add it in with a default of the post title.
preg_match_all('//', $content, $images);
foreach($images as $index => $value)
$new_img = str_replace('<img', '"'.$post-post_title.'"', $images[$index]);
$content = str_replace($images[$index], $new_img, $content);
add_filter('the_content', 'add_alt_tags', 99999);