Getting images to show up in RSS Reader

I’m trying to get posts’ featured images to show up in RSS Reader.

When I look at the raw RSS XML I can see the images are successfully being written into <description> and also under <post-thumbnail> (via a function I found on a thread here) but I don’t see the images showing along with the excerpt in Google Reader, for example.

Read More

I’m using the following function / filters:

function insertThumbnailRSS($content) {
    global $post;
    if(has_post_thumbnail($post->ID)){
        $content = ''.get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => get_the_title(), 'title' => get_the_title(), 'style' => 'float:left;')).''.$content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'insertThumbnailRSS');
add_filter('the_content_feed', 'insertThumbnailRSS');

add_action('rss2_item', function(){
  global $post;

  $output = '';
  $thumbnail_ID = get_post_thumbnail_id( $post->ID );
  $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail');
  $output .= '<post-thumbnail>';
    $output .= '<url>'. $thumbnail[0] .'</url>';
    $output .= '<width>'. $thumbnail[1] .'</width>';
    $output .= '<height>'. $thumbnail[2] .'</height>';
    $output .= '</post-thumbnail>';

  echo $output;
});

Related posts

Leave a Reply

1 comment

  1. Zach was correct. The RSS feed updated itself with my latest changes in about an hour. This function works, and I love the ability to CSS style the image as well.