Results 1 to 3 of 3

Thread: RSS Display Box image thumbnail

  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default RSS Display Box image thumbnail

    1) Script Title: RSS Display Boxes

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ybox/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.

  2. #2
    Join Date
    Aug 2004
    Posts
    9,876
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    You might try editing outputbody.php of the script, specifically, the "default template" portion of the code:

    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.
    DD Admin

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,920
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    I'd be inclined to leave that part alone and to edit the simplepie.inc file. Around line #1248 you see:

    Code:
    	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:

    Code:
    <?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.
    Last edited by jscheuer1; 03-24-2011 at 02:06 PM. Reason: add bit about link to feed
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •