Add the featured image to the WordPress RSS feed

Recently, there was a requirement to add the featured image to the RSS feed for the San Diego Tourism Authority's leisure blog.

Here's how to do it.

First find the functions.php file.

Add the code below at the very bottom of the file.

function post_thumbnails_in_feed( $content ) {
    global $post;
    if( has_post_thumbnail( $post->ID ) ) {
        $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>' . $content;
    return $content;
add_filter( 'the_excerpt_rss', 'post_thumbnails_in_feed' );
add_filter( 'the_content_feed', 'post_thumbnails_in_feed' );

That alone should do it, but if you need the image to have it's own node in the feed, then you need to go one step further. Find the appropriate feed template. In my case it was feed-rss2.php. Then search for the <item> node and right after that you should see a <title> node. Add this line right after the title node.
 <featuredimage><?php echo the_post_thumbnail_url(  $post->ID ); ?></featuredimage>