WordPress.org

Ready to get started?Download WordPress

Forums

Super RSS Reader
[resolved] How to display thumbnail ? doesnt work at my wp site v.3.5.1 (14 posts)

  1. mtstawski
    Member
    Posted 1 year ago #

    Hey,

    How can I display thumbnail with your plugin ??
    My WP site is version 3.5.1.

    Thumbnails are available with my rss feed.

    Help !!

    http://wordpress.org/extend/plugins/super-rss-reader/

  2. 3mealsaday
    Member
    Posted 1 year ago #

    I am trying to sort this one out myself. I have one feed that I know has thumbnails but it shows no images.

    http://www.amazon.com/gp/rss/new-releases/books/6/ref=zg_bsnr_6_rsslink

    Then I have another that also has images and it shows some of them but not all.

    The standard WP RSS widget behaves the same way.

    The RSS Multi-Importer RSS feed imports with all the pictures but does not provide the other features I prefer with this plugin I am testing.

    Unclear if I will stick with this one or not. I have created a few different styles so it would be a shame to cross this one off.

  3. Jarada
    Member
    Posted 1 year ago #

    At the moment, as far as I can tell, thumbnail images will only display if you are showing the RSS description. Make sure you have Show Description ticked in your options.

    If you want to show Thumbnails without the description, a temporary workaround would be to go into the Plugin Editor and edit the file super-rss-reader/super-rss-reader.php.

    Find the following code:

    $thumb = '';
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
      $thumburl = $enclosure->get_thumbnail();
      if(!empty($thumburl))
        $thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    And change it so it reads:

    $thumb = '';
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
      $thumburl = $enclosure->get_thumbnail();
      if(!empty($thumburl))
        $thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }
    if (!$show_desc && $show_thumb) $title = $thumb . $title;

    This will display the thumbnail to the left of the title.

  4. trashandsuicide
    Member
    Posted 11 months ago #

    Hey Jarada, this totally doesn't work for me.

    Here's my feed: http://9to5.cc/keith/feed/ which has the code (for example):
    <enclosure url="http://9to5.cc/keith/files/2013/08/dirties1-150x150-1376497869.jpg" length="10515" type="image/jpg"/>

    But no thumb is showing.

    And here is how the plugin appears: http://9to5.cc/test/

  5. Chastise
    Member
    Posted 10 months ago #

    I'm having the same issue.

    Guess I will have to find a different widget?

  6. Indione
    Member
    Posted 9 months ago #

    The images don't for me either. I'm using Interspire Shopping Cart feeds. I don't see how this plugin is grabbing the image. If it grabs it from the description, it would be grabbing the wrong image anyway like the multi rss importer did. This is the enclosure for the Interspire thumbnail image in the rss feed: <isc:thumb>

  7. letsjump
    Member
    Posted 7 months ago #

    Some other dirty temporary workarounds.
    In my case, the image is embedded in the rss description tag like in the example:
    <description><![CDATA[ <img src="http://www.my-site-rss.com/post/13/12087/12087/small.jpg" alt="alt" /> other rss description text ... ]]> </description>
    So I can extract the src attribute of my image tag using dwo different php function.
    The first, the bad one, with some bad and slow regex code:

    preg_match_all('/<img src=\"(.*?)\".*\/>/', $item->get_description(), $images);
    $thumb = '';
    if ($show_thumb == 1 && !empty($images[1][0])){
       $thumb = '<img src="' . $images[1][0] . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    The second one, if your server come with DOM functions, you can fastly extract your URL:

    $doc = new DOMDocument();
    $doc->loadHTML("<p>".$item->get_description()."</p>");
    $tags = $doc->getElementsByTagName('img');
    foreach ($tags as $tag) {
       $src[] = $tag->getAttribute('src');
    }
    if ($show_thumb == 1 && !empty($src)){
       $thumb = '<img src="' . $src[0] . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }
  8. letsjump
    Member
    Posted 7 months ago #

    A last elegant solution consists in replacing this code

    // Get thumbnail if present @since v2.2
    $thumb = '';
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
    	$thumburl = $enclosure->get_thumbnail();
    	if(!empty($thumburl))
    		$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    with this one that will search the image tag in the description too:

    $thumb = '';
    if($show_thumb == 1) {
    	$enclosure = $item->get_enclosure();
    	// if we have a proper XML tag for our rss-feed image
    		if(!empty($enclosure->thumbnails)) {
    			$thumburl = $enclosure->get_thumbnail();
    			// else we will search a <img> tag in our description
    		} elseif(stripos($item->get_description(), 'formula') !== false) {
    
    		// is DOM module present in our PHP installation?
    		if (class_exists('DOMDocument')) {
    			$dom = new DOMDocument();
    			$dom->loadHTML("<div>".$item->get_description()."</div>");
    			$images = $dom->getElementsByTagName('img');
    			foreach($images as $image) {
    				$src[] = $image->getAttribute('src');
    			}
    			$thumburl = $src[0];
    
    		// if not, we will use a slower preg_match regex...
    		} else {
    			$images = Array();
    			preg_match_all('/ src=\"(.*?)\".*\/>/', $item->get_description(), $images);
    			$thumburl = $images[1][0];
    		}
    	}
    	// if, at last, we have filled our $thumburl
    	if(!empty($thumburl)) {
    		$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    	}
    }
  9. letsjump
    Member
    Posted 7 months ago #

    So, the last working version is:

    $thumb = '';
    if($show_thumb == 1) {
    	$enclosure = $item->get_enclosure();
    	// if we have a proper XML tag for our rss-feed image
    	if(!empty($enclosure->thumbnails)) {
    		$thumburl = $enclosure->get_thumbnail();
    
    	// else we will search a <img> tag in our description
    	} else
    	if(stripos($item->get_description(), '<img') !== false) {
    
    		// is DOM module present in our PHP installation?
    		if (class_exists('DOMDocument')) {
    			$dom = new DOMDocument();
    			$dom->loadHTML("<div>".$item->get_description()."</div>");
    			$images = $dom->getElementsByTagName('img');
    			$src = Array();
    			foreach($images as $image) {
    				$src[] = $image->getAttribute('src');
    			}
    			$thumburl = $src[0];
    
    		// if not, we will use a slower preg_match regex...
    		} else {
    			$images = Array();
    			preg_match_all('/ src=\"(.*?)\".*\/>/', $item->get_description(), $images);
    			$thumburl = $images[1][0];
    		}
    	}
    // if, at last, we have filled our $thumburl
    	if(!empty($thumburl)) {
    		$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    	}
    }
  10. genuskbl
    Member
    Posted 5 months ago #

    Salam,

    i run into this problem just now and i noticed that the above code is missing another part where you need to add $thumb in output.
    so for me this is the working version.
    1. make sure your feed has enclosure check at
    yourblog.com/category/feed
    1.i if your feed doesn't have enclosure please add this code to your theme's function.php file

    add_action('rss2_item', function(){
      global $post;
    
      $output = '';
      $thumbnail_ID = get_post_thumbnail_id( $post->ID );
      $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail');
      $mime = get_post_mime_type($thumbnail_ID);
      $output = '<enclosure url="'.$thumbnail[0].'" type="'.$mime.'"/>';
      echo $output;
    });

    2. go into the Plugin Editor and edit the file super-rss-reader/super-rss-reader.php replace this code for me its on 325th line.

    // Get thumbnail if present @since v2.2
    $thumb = '';
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
    	$thumburl = $enclosure->get_thumbnail();
    	if(!empty($thumburl))
    		$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    with this

    // Get thumbnail if present @since v2.2
    				if($show_thumb == 1) {
     				$enclosure = $item->get_enclosure();
    				// if we have a proper XML tag for our rss-feed image
    				if($enclosure->get_link()) {
    					$thumburl = $enclosure->get_link();
    				// else we will search a <img> tag in our description
    				} else{
    					$thumburl = "url to temp image.png";//$item->get_thumbnail();
    				}
    				// if, at last, we have filled our $thumburl
    				if(!empty($thumburl)) {
    					$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" style="float: right !important;margin: 0 0 0 10px!important; border: 1px solid;30px !important"/>';
    				}
    				}
     				// end if show tabs

    in above code there "url to temp image.png don't forget to replace it with your own temp image in case the thumbnail is not available.
    and also you can change the style style="float: right !important;margin: 0 0 0 10px!important; border: 1px solid;30px !important" to whatever you like i wanted the image to show on the right side of title.

    3. on the same file find // Display the feed items
    original code

    echo '<div class="srr-title"><a title="Posted on ' . $date . '">' . $title . '</a></div>';

    i wanted the image to show on the right side of my feed title.
    so i changed to

    echo '<div class="srr-title"><a title="Posted on ' . $date . '">'.$thumb. $title . '</a></div>';

    see above i added $thumb before title

    that's all hope it helps some one.
    Best, From Afghanistan.

  11. Er_Maqui
    Member
    Posted 5 months ago #

    A bit of workaround this:

    On my case, i have Super RSS Reader reading feed from another wordpress installs. They send a link to image on enclosure item thanks to another plugin called "Insert RSS Thumbnails". The problem are, who they doesn't send "Thumbnail" tag, instead send directly the "link" tag on Enclosure.

    The info received on the Super RSS Reader (Thanks to var_dump($enclosure), but I've deleted the NULL values except one for better legibility):

    NULL
    object(SimplePie_Enclosure)#5644 (27) {
      ["length"]=>
      float(2854)
      ["link"]=>
      string(58) "http://semosfrikis.blogs.enelia.com/files/2013/12/logo.png"
      ["restrictions"]=>
      array(1) {
        [0]=>
        object(SimplePie_Restriction)#5647 (3) {
          ["relationship"]=>
          string(5) "allow"
          ["type"]=>
          NULL
          ["value"]=>
          string(7) "default"
        }
      }
      ["thumbnails"]=>
      NULL
      ["type"]=>
      string(10) "image/jpeg"
    }

    A little solution, but very effective:

    Find:

    $thumb = '';
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
      $thumburl = $enclosure->get_thumbnail();
      if(!empty($thumburl))
        $thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    Change with:

    // Get thumbnail if present @since v2.2
    $thumb = '';
    
    if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
    	$thumburl = $enclosure->get_thumbnail();
    	if(empty($thumburl)) $thumburl = $enclosure->get_link();
    	if(!empty($thumburl))
    	$thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
    }

    The only change are this line:
    if(empty($thumburl)) $thumburl = $enclosure->get_link();

    I think, some of this changes can be a good change for the plugin mainstream. Not neccesary my change.

  12. genuskbl
    Member
    Posted 5 months ago #

    @Er_Maqui

    i haven't tested your solution but for one part it, you still need to echo $thumb on the output.

  13. Er_Maqui
    Member
    Posted 5 months ago #

    @genuskbl

    In my case, I'm showing description. Because this, this solution it's working.

    But, also, this can be a good idea. The plugin have a "show thumb" option, the mantainer can change the code to show thumb always they're selected and available, not only when show description (long text).

  14. genuskbl
    Member
    Posted 5 months ago #

    @Er_Maqui
    Indeed, but my solution was for only title and thumbnails. so for those who likes to show only title and thumbnail it they must do that because the plugin will not print the thumb otherwise.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic