Fix image URLs in Wordpress RSS feed

Recently I had to fix a RSS feed export for Wordpress thus it includes a FQDN in IMG path.

There are some other buggy solutions on the web, thus here is my own: it goes into functions.php of your theme:

function add_url($match) {
        return $match[1] . get_site_url() . $match[2];
}

function add_image_into_rss_feeds($content) {
        return preg_replace_callback('/(<img.+src=[\'"])([^\'"]+[\'"][^>]*>)/i', 'add_url', $content);
}

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

May be it's not perfect, but it works, as it should at least.

Disclamer: I'm not a PHP programmer at all, not even a bit, but I think it's worth share. Suggestions are welcome.