Viewing 1 replies (of 1 total)
  • Plugin Author Chris Scott

    (@chrisscott)

    Since there’s no helper in WP to get the alt attribute, you’d have to do something like:

    attachment_id = MultiPostThumbnails::get_post_thumbnail_id( $post_type, $id, $post_id );
    $alt = '';
    $alt = trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) );
    
    if ( ! $alt ) {
      $attachment = get_post( $attachment_id );
      $alt = trim(strip_tags( $attachment->post_excerpt )); // Use Caption
      if ( ! $alt ) {
          $alt = trim(strip_tags( $attachment->post_title )); // Use Title
      }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Alt tags’ is closed to new replies.