简体   繁体   中英

Getting Thumbnail from RSS Feed and Display in Listview

i need some help with my RSS Feed Reader Script... I want Thumbnails in my Listview taken from Rss Feeds Thumbnail

"content": [
      {
       "medium": "image",
       "url": "http://www......de/wp-content/uploads/2010/11/sgroth_web.jpg",
       "title": {
        "type": "html",
        "content": "sgroth_web"
       },
       "description": {
        "type": "html",
        "content": "contenthere 4."
       },
       "thumbnail": {
        "url": "http://www.sdddd.de/wp-content/uploads/2010/11/sgroth_web-150x150.jpg"
       }

have a look what i mean: Preview

First comes the Thumbnail and then the Title of the Rss Feed.. This Code is Jquery and PHP...

and here is my Code to Display RssFeeds in JS:

$(function(){


getOnlineFeed('http://salzstreuner.de/category/aktuelle_ausgabe/feed');
    });
/* functions */
var listEntries = function(json) {
  if (!json.responseData.feed.entries) return false;
  $('#widgetTitle').text(json.responseData.feed.title);
  var articleLength =json.responseData.feed.entries.length;
  articleLength = (articleLength > maxLength) ? maxLength : articleLength;
  for (var i = 1; i <= articleLength ; i++) {
    var entry = json.responseData.feed.entries[i-1];
    $('#link' + i).text(entry.title);
    $('#articleHeader' + i).text(entry.title);
    $('#openButton' + i).attr('href', entry.link);
    $('#articleContent' + i).append(entry.content);
 $('#articleImage').append('<img src="' + entry.thumbnail + '">');
  }
  $('#article1 .prevButton').remove();
  $('#article' + articleLength + ' .nextButton').remove();
  if (articleLength < maxLength) {
    for (i = articleLength + 1; i <= maxLength; i++) {
      $('#list' + i).remove();
      $('#article' + i).remove();
    }
  }
};
var getOnlineFeed = function(url) {
  var script = document.createElement('script');
  script.setAttribute('src', 'http://ajax.googleapis.com/ajax/services/feed/load?callback=listEntries&hl=ja&output=json-in-script&q='
                      + encodeURIComponent(url)
                      + '&v=1.0&num=' + maxLength);
  script.setAttribute('type', 'text/javascript');
  document.documentElement.firstChild.appendChild(script);
};
var getOfflineFeed = function(url) {
  var script = document.createElement('script');
  script.setAttribute('src', url);
  script.setAttribute('type', 'text/javascript');
  document.documentElement.firstChild.appendChild(script);
};

Output looks like This:

for(var i=1; i<=maxLength; i++){
  document.write(
    '<li id="list' + i + '"><img src="#articleImage"/><a href="#article' + i + '" id="link' + i + '">&nbsp;</a></li>'
  );

I have Played with #articleImage but it doesn't work. I hope someone Outside can help me with this littleBig Problem...

THX MAsterluke

您应该使用thumbnailurl

('#articleImage').append('<img src="' + entry.thumbnail.url + '">');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM