warnerr
warnerr

Reputation: 137

Displaying Thumbnail from RSS Feed

I am currently displaying an RSS feed and I am grabbing the title, link and date for each article. I would also like to grab the media:thumbnail for each article. Here is the PHP code I am using to retrieve the RSS feed.

<?php
                $rss = new DOMDocument();
                $rss->load('http://www.avfc.co.uk/rss/ptv/page/CustomArticleIndex/0,,10265~2282152,00.xml');
                $feed = array();



                foreach ($rss->getElementsByTagName('item') as $node) {
                $item = array ( 
                'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
                'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
                'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,

                 );
                array_push($feed, $item);
                 }
                 $limit = 2;
                for($x=0;$x<$limit;$x++) {
                 $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
                $link = $feed[$x]['link'];
                $date = date('l F d, Y', strtotime($feed[$x]['date']));


                echo '<div id="feed"><a target="_blank" href="'.$link.'" title="'.$title.' ">'.$title.'</a><br />';
                echo '<a class="date">Posted on '.$date.'</a></div>';



                 }
                ?>

The RSS feed I am displaying is: http://www.avfc.co.uk/rss/ptv/page/CustomArticleIndex/0,,10265~2282152,00.xml

I'm not that good with PHP so does anybody know how I can go about doing this? Thanks.

Upvotes: 0

Views: 1610

Answers (1)

mblitz
mblitz

Reputation: 189

Try that:

$thumb = $node->getElementsByTagName('media:thumbnail')->item(0)->attributes->getNamedItem('url')->nodeValue;

Upvotes: 0

Related Questions