title: Add alt text for missing alt images for whole website
body: <p>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</p>
  <pre><code>function add_alt_to_images_if_missing( $attr, $attachment = null ) {
  if($attr['alt']==''){
      $attr['alt']=trim( strip_tags( $attachment-&gt;post_title ) );
  }
  return $attr;
  }
  add_filter( 'wp_get_attachment_image_attributes','add_alt_to_images_if_missing', 10, 2 );
  </code></pre>