<?php
/*
Plugin Name: Feed Images
Description: Adds your post thumbnails to your feed in <img> tags.
Version: 1.0
Author: John Blackbourn
Author URI: http://johnblackbourn.com/
Built for Bas Prinsen by John Blackbourn
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
function feed_img( $content ) {
if ( function_exists( 'get_the_image' ) and ( $thumb = get_the_image('format=array') ) ) {
$thumb[0] = $thumb['url'];
} else if ( function_exists( 'has_post_thumbnail' ) and has_post_thumbnail() ) {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumbnail' );
} else if ( function_exists( 'get_post_thumbnail_src' ) ) {
$thumb = get_post_thumbnail_src();
if ( preg_match( '|^<img src="([^"]+)"|', $thumb[0], $m ) )
$thumb[0] = $m[1];
} else {
$thumb = false;
}
if ( $thumb )
$content = '<img src="' . $thumb[0] . '" /> ' . $content;
return $content;
}
add_filter( 'the_excerpt_rss', 'feed_img' );
?>