How to add Featured Images to your WordPress RSS Feed

I discovered today that featured images are not added to WordPress RSS feeds by default. Following the Specifications here is a quick snippet that you can add to your functions.php file and get those images back in place.

As always, mileage may vary. Leave a comment if you have updates/issues/enhancements/etc.

function add_thumbnail_to_rss() {
    global $post;
        $content = get_the_post_thumbnail_url($post->ID);
        $bytes = filesize(get_attached_file(get_post_thumbnail_id()));
        echo('<enclosure url="' . $content . '" length="' . $bytes . '" type="image/jpg" />');

add_action('rss2_item', 'add_thumbnail_to_rss');


Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.