You can customize your WordPress blog or site homepage and inner archives by showing a cute little thumbnail image on the left or right and then putting the post excerpt beside. Most of the themes have this feature. But we don’t have an inbuilt feature to have those thumbnails in our blog RSS feeds. So, I would like to show you how you can add a thumbnail to your site RSS feed using a very lightweight and extremely well coded plugin by Justin Tadlock and putting a small code in your active theme’s function.php (this small code is written and fully tested by me, you can check our RSS feed
)
There is no need that you set a post thumbnail or a featured image (WordPress 3.0 nomenclature) for each and every post to get it in the RSS for that article. The plugin will scan the post and pull a thumbnail as follows:-
- Looks for an image by custom field (default custom field is “thumbnail”).
- If no image is added by custom field, check for a post image (WordPresss 2.9+ feature).
- If no image is found, it grabs an image attached to your post.
- If no image is attached, it can extract an image from your post content.
- If no image is found at this point, it will default to an image you set.
As well you can specify any custom size for the image fetched.
Two steps to get it working
Step 1: Download the WordPress Plugin “Get the Image” from WordPress Plugin Directory and activate it. It is a very powerful wordpress plugin, which do not load any CSS or javascript in your page header. It is just a new template tag which enhances the WordPress thumbnail image fetching.
Step 2: Include this small piece of code in your theme’s functions.php file. You can edit this file thru your WordPress Theme Editor. Go to Dashboard—>Appearance—>Editor and select “Theme Functions” from the right hand Templates list. Include the below code before the closing php tag (?>), if this tag is not present at the end, just put the code at the end.
function display_post_thumbnail_in_rss($rss_content) {
global $post;
if ( function_exists( 'get_the_image' ) ) {
$rss_content= '<div style="float : left;margin-right:10px;">'.get_the_image(array( 'default_image' => '', ‘image_scan’ => true, 'width' => '150', 'echo' => false ) ). '</div>'.$rss_content;
}
return $rss_content;
}
add_filter('the_content_feed', 'display_post_thumbnail_in_rss');
add_filter('the_excerpt_rss', 'display_post_thumbnail_in_rss');
In the above code, you can put the url of a standard/default image which will be shown in the RSS, if there is no custom field or thumbnail or image found attached to the post. As you can see in the code, you can specify the width of the image. If you do not specify the height, it will take the height as proportional to width (this is good, I must say!), but yes, you can definitely specify the height separately. Also, you can specify any CSS to the image, yeah, that would be an inline CSS.
After finishing the above two steps, just refresh your blog’s RSS feed by publishing a test post or a regular post. And you can see the thumbnail images floating to the left side of the content in the reader, may be you can check in Google reader or whatever reader of your choice. Doesn’t that look awesome, tell me??
This is useful when you show excerpts in your blog’s RSS feed rather than complete content. But still those of you who keep complete content in RSS, can as well use this feature to display a very small image at the start of the article in RSS, so that the feed looks attractive and engaging.
In my blog’s feed screenshot, attached above, I am using Google Chrome browser with RSS Subscription Google Chrome Extension to read the RSS.
If you got it working, do share it with all our readers thru the comments section below.

Avoid No Thumbnail Or Unrelated Thumbnail Image While Sharing Post On Facebook
Sovereign – Clean, Professional Premium WordPress Theme
Get Recent Posts From Various Blogs On WordPress MU Site
Optimize WordPress Blogs for iPhone, BlackBerry or Other Touchscreen Smartphones
Solution for WordPress WP Super Cache Broken Or Not Working
Tagged: code, feed, function, how to, reader, rss, template, thumbnail, Wordpress, wordpress plugin
No Trackbacks
You can leave a trackback using this URL: http://www.staenzwebsolutions.com/how-to-add-post-thumbnail-or-a-thumbnail-image-to-wordpress-rss-feeds/442/trackback/
2 Comments
nice info,…..
i will try this with my blog…….
You’re my hero! Worked like a charm. Thanks for sharing!