<?php
/**
 * Add post type images to feed items
 */
add_action('rss2_item', 'add_images_in_feed' );
function add_images_in_feed() {
	global $post;

	// Thumbnail...
	$thumbnail_ID = get_post_thumbnail_id( $post->ID );
	if ( $thumbnail_ID ) {
		$thumbnail = wp_get_attachment_image_src( $thumbnail_ID, 'full' );
		$thumbnail_size = filesize( get_attached_file( $thumbnail_ID ) );
		$thumbnail_mime = get_post_mime_type( $thumbnail_ID );
?>
		<enclosure url="<?php echo $thumbnail[0]  ?>" length="<?php echo $thumbnail_size  ?>" type="<?php echo $thumbnail_mime  ?>" />
<?php
	}

	// ...and other attachments
	$args = array(
		'order'          => 'ASC',
		'post_type'      => 'attachment',
		'post_parent'    => $post->ID,
		'post_mime_type' => 'image',
		'post_status'    => null,
		'numberposts'    => 1,
	);
	$attachments = get_posts( $args );
	if ( $attachments ) {
		foreach ( $attachments as $attachment ) {
			if ( $thumbnail_ID !== $attachment->ID ) {
				$image = wp_get_attachment_image_src( $attachment->ID, 'full' );
				$filesize = filesize( get_attached_file( $attachment->ID ) );
				$mime = get_post_mime_type( $attachment->ID );
				if ( $image ) {
?>
		<enclosure url="<?php echo $image[0] ?>" length="<?php echo $filesize ?>" type="<?php echo $mime ?>" />
<?php
				}
			}
		}
	}
}

?>