Add Image in WordPress Feed

Feed Summary

Feed is one of the important things in blog. Usually we use RSS feed in WordPress or Feedburner to serve our reader. Apart from the purpose, sometime when you put your link on other website, depending on the method of fetching, it may use your feed to provide preview of the link you provided. Image in feed will help in making the feed beautiful and presentable to the reader. Most of the time, your wordpress theme has include this feature to include image whenever possible in your feed. However if you doesn’t see any image in your feed, then this post will guide in adding the image in your feed.

There are several cases that may result image in a post not included in the feed.

Theme doesn’t include the feature to add image into feed

If this is the matter, you can try to put the code below in your theme functions.php file. Add it anywhere which you find suitable or just put the code at the bottom of the file.

function invialgo($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content;
return $content;

add_filter('the_excerpt_rss', 'invialgo');
add_filter('the_content_feed', 'invialgo');

Please take note that the code above will use featured image in your post to be as the image in the feed.

Add Image in Feed without Featured Image

There are cases which you don’t set the featured image in a post. This may happen either your forgot to do so or maybe you start using wordpress long time ago which featured image feature not yet implemented at that time. If that is the case, you may use the code below. This code will try to find the first image in your post and use it as image in your feed.

function invialgo_first_image() {
	global $post;

	$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );

	if ($photos) {
		$photo = array_shift($photos);
		$invialgo = wp_get_attachment_image_src($photo->ID);
		return $invialgo[0];
    return false;

function insert_img($content) {
		$img = '<img src="'.invialgo_first_image().'" alt="'.get_the_title().'" /><br />';
		$content = $img.$content;
    return $content;

add_filter('the_excerpt_rss', 'insert_img');
add_filter('the_content', 'insert_img');

The code above will try to find the first image in a post to make it as a image in your feed.


Set Featured Image Automatically for old post

Here is another solution to solve your problem. Since you don’t set featured image for your old post, how about you try to use wordpress plugin Auto Post Thumbnail. This great plugin will help you find image in your post and set it as featured image automatically. In a single click, all your post will have featured image set. This plugin will use first image in a post or any image if the first image somehow doesn’t work or invalid. If you already set featured image in a post, it will respect your decision and will not change set new featured image.

Auto Post Thumbnail

Once you have generate post thumbnails for all the posts, you may use the first code at the top of this post to add image to your feed. You may use your built in theme code to add image in RSS feed which normally use featured image as the method.


Set Summary or Full Text for Feed

A little bit out of topic, but if you unable to find how to set summary or full text feed, you may find it in WordPress “Reading Setting” which stated “For each article in a feed, show”. You then can select either full text or summary feed.

Feed Summary

For Feedburner user, please be reminded if you made any changes either to your code or featured image, you might not see the result immediately. You may try to ping feedbuner to  see immediate result.

All the codes above not fully created by me. I just edit several code in other website and combined it to serve the purpose. I’m not a good programmer. My code doesn’t work, i don’t know why, my code works, i don’t know why. So if you have better suggestion, please leave comment below.

Thank You

Sharing is Caring

Leave a Reply

Your email address will not be published. Required fields are marked *