Ryan helped me with this awhile back, play with it a lot you'll figure it
out.

<?php
require_once('../php/simplepie.inc');
$feed = new SimplePie();
$feed = new SimplePie('http://feeds.feedburner.com/somefeed/sogj');
$feed->handle_content_type();
$feed->init();
//Get an image
function returnImage ($text) {
    $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
    //echo $text;
    $pattern = "/<img[^>]+\>/i";
    preg_match($pattern, $text, $matches);
    $text = $matches[0];
    return $text;
}
////////////////////////////////////////////////////////////////
//Filter out image url only
function scrapeImage($text) {
    $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
preg_match($pattern, $text, $link);
if(empty($link))
   $link = 'http://default-image-location.com/some-image.jpg';
else
   $link = $link[1];
return $link;
}
?>


*Then output it like so:*

echo '<img title="some titile" src="' .$image. '"/>';

Reply via email to