PDA

View Full Version : RSS Display Box image thumbnail



CEDC
03-22-2011, 04:31 PM
1) Script Title: RSS Display Boxes

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/rssdisplaybox/index.htm

3) Describe problem: I'm trying to get my rss display box to feature a thumbnail image for each blog entry. I have made sure my blog (wordpress) can create thumbnails but I'm not sure what to link to for the rss box to display the thumbnail. Is this possible to do?

Any help is greatly appreciated.

Thanks.

ddadmin
03-23-2011, 05:49 AM
You might try editing outputbody.php of the script, specifically, the "default template" portion of the code:


if ($template=="" || $template=="default"){ //DEFAULT TEMPLATE
?>
<DIV class="rsscontainer">
<div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></div>
<div class="rssdate"><?php echo $item->get_date('d M Y g:i a'); ?></div>
<div class="rssdescription"><?php echo $item->get_description(); ?></div>
</DIV>
<?
}

The line in red is responsible for the retrieval of the BODY of each RSS entry. I'm very rusty when it comes to Simplepie and how the get_description() method behaves, but if you're familiar with PHP, try deciphering/ hacking this method to get it to also retrieve any image within the RSS BODY.

jscheuer1
03-23-2011, 02:21 PM
I'd be inclined to leave that part alone and to edit the simplepie.inc file. Around line #1248 you see:


function get_description()
{
if (!empty($this->data['content']))
{
return $this->data['content'];
}
else if (!empty($this->data['encoded']))
{
return $this->data['encoded'];
}
else if (!empty($this->data['summary']))
{
return $this->data['summary'];
}
else if (!empty($this->data['description']))
{
return $this->data['description'];
}
else if (!empty($this->data['dc:description']))
{
return $this->data['dc:description'];
}
else if (!empty($this->data['longdesc']))
{
return $this->data['longdesc'];
}
else
{
return false;
}
}

It doesn't take much to see that, if any of the highlighted are available, the full description will not be used. If your thumbnail is in the description, removing or commenting the highlighted will ensure it gets imported.

So, keep a backup of simplepie.inc and edit one for your use:


<?php
function get_description()
{
/* if (!empty($this->data['content']))
{
return $this->data['content'];
}
else if (!empty($this->data['encoded']))
{
return $this->data['encoded'];
}
else if (!empty($this->data['summary']))
{
return $this->data['summary'];
}
else */ if (!empty($this->data['description']))
{
return $this->data['description'];
}
else if (!empty($this->data['dc:description']))
{
return $this->data['dc:description'];
}
else if (!empty($this->data['longdesc']))
{
return $this->data['longdesc'];
}
else
{
return false;
}
}
?>

If your thumbnail is somewhere else in the xml structure of the feed (other than in the description tag), we need to know where and find a way to retrieve it. If it comes to that, you could give us a link to the feed so we could check it out.

Note: The current simplepie.inc (it's been updated several times since this script came out) allows you to retrieve the full description without needing to be edited. But to switch to it, both outputbody.php and main.php would need to be edited because some of the function names have changed, as has the way that cache times are calculated. And it might be a bit more complicated, as the updated simplepie.inc does a better job at filtering out images, so part of that might have to be dealt with in configuring the feed with it as well.