I've had a search and I can't see a similar post, so I thought I'd start my own. I have recently discovered and started to use SimplePie to integrate feeds into websites. It's a great tool, and works well.
However, I now want to display just the first image from inside the content of a post with a caption, or short description. This is proving to be somewhat of a challenge for my naive brain.
Here's my code:
//get the simplepie library
//grab the feed
$feed = new SimplePie('http://ameenakaracallender.blogspot.com');
//provide the caching folder
//set the amount of seconds you want to cache the feed
//init the process
//let simplepie handle the content type (atom, RSS...)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RSS Feed Reader test page</title>
<?php foreach ($feed->get_items() as $item): ?>
<h2><?php echo $item->get_title(); ?></h2>
<h4><?php echo $item->get_date(); ?></h4>
<?php echo '<img src="' .$item->get_first_image_url(). '"/>'; ?>
<?php endforeach; ?>
The get_first_image_url command, is obviously pseudocode, and I have no idea how to create that function, but essentially that's what I need.
Any help would be great.
Many thanks in advance,