繁体   English   中英

从RSS源获取缩略图并在Listview中显示

[英]Getting Thumbnail from RSS Feed and Display in Listview

我的RSS Feed阅读器脚本需要一些帮助...我希望Listview中的缩略图取自Rss Feeds缩略图

"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"
       }

看看我的意思: 预览

首先是缩略图,然后是Rss Feed的标题。。此代码是Jquery和PHP ...

这是我在JS中显示RssFeeds的代码:

$(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);
};

输出看起来像这样:

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>'
  );

我已经玩过#articleImage,但是它不起作用。 我希望外面的人可以帮助我解决这个littleBig问题...

THX MAsterluke

您应该使用thumbnailurl

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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