WordPress is a great open source project for blogging and content management. Millions of users use it everyday. RSS (Really Simple Syndication) feed is a very commonly used feature among bloggers to broadcast latest posts and updates.
Unfortunately, the default WordPress RSS does not include any media items. Some bloggers said the image URL will be included if you choose Full Text under Settings—Reading–For each article in a feed, show. Unfortunately this is not true for the default templates (Twentyten or Twentyeleven).
There are different ways to include images in the RSS feed. You can directly modify the feed-rss2.php under wp-includes directory.
The safer way to modify the default RSS feed behavior is through your template. This will avoid some possible issues in future upgrade. So, here is how to put the URL of the first image in your RSS feed.
Corresponding to your theme (template), there is a file named functions.php, in which most template related functions (e.g., rendering comments) are placed. So, you can open this file with any text editor (e.g., Notepad++), and scroll all the way to the end, and put the following code:
function add_image_into_rss_feeds($content) {
global $post, $posts;
$img_url_to_be_inserted = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$img_url_to_be_inserted = $matches [1] [0];
if(!empty($img_url_to_be_inserted)){
$content = '<img src="' . $img_url_to_be_inserted . '">' . $content;
}
return $content;
}
// if you want to include image when using excerts, uncomment the following line
// add_filter('the_excerpt_rss', 'add_image_into_rss_feeds');
add_filter('the_content_feed', 'add_image_into_rss_feeds');
Now, add a new post with an image, then generate the new RSS feed. You images should show up properly. A working example is a funny picture blog. You may check the feed here: http://feeds.feedburner.com/JokeslabMedia
For some reasons, you may need use VPN service. If you do not have a…
Virtual Private Network (VPN) is the most effective way to bypass access control, the censorship,…
As a free hosting provider, you budget is always tight. Even if you have a…
404 page can be your invisible cash cow!. As I mentioned in the previous post…
Some consultants may tell you as a free hosting provider, you should stay away from…
Most people believes that a good domain can attract and retain users for your free…
View Comments
What do you mean 'generate the new RSS feed'
Does this go on the blog that the feed comes from, or the blog that's importing the feed????
you can just go to your blog's feed url to check the new feed.