When year ago I was working on new functions for e-art.lv, I decide to use Post Thumbnails In WordPress Feeds. There were several reasons why we (e-art.lv) started to use that “feature“. We saw that some of RSS aggregators are usign these features from other RSS and Atom feeds. We wanted them too… Here is my solution for post thumbnails in WordPress excerpt feeds.
Code of Post Thumbnails In WordPress Feeds
// Post thumbnails in RSS from Simple Media Code http://blog.simplemediacode.com/?p=248 by http://Umbrovskis.com
function me3_rssthumbnails($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'medium', array('align' => 'left', 'alt' => $post->post_title)) . "\n" . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'me3_rssthumbnails');
Here comes code explanation:
we are taking existing content of RSS
me3_rssthumbnails($content)
we are taking uploaded image from post
has_post_thumbnail( $post->ID ))
Here we are taking medium size image from post, aligning it to left, and taking post title as descriptional text in alt attribute.
$post->ID, 'medium', array('align' => 'left', 'alt' => $post->post_title)
Download as WordPress plugin
More info about used WordPress functions
- http://codex.wordpress.org/Function_Reference/has_post_thumbnail
- http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
- http://codex.wordpress.org/Function_Reference/add_filter












