【问题标题】:Getting Thumbnail from RSS Feed and Display in Listview从 RSS Feed 获取缩略图并在 Listview 中显示
【发布时间】:2011-05-20 17:00:58
【问题描述】:

我需要一些关于我的 RSS 提要阅读器脚本的帮助... 我想要从 Rss Feeds Thumbnail 获取的 Listview 中的缩略图

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

看看我的意思: Preview

首先是缩略图,然后是 Rss 提要的标题。 这段代码是 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,但它不起作用。我希望外面的人能帮我解决这个小问题......

THX 马斯特鲁克

【问题讨论】:

  • 那么到底是什么问题呢?它应该做什么,它没有做什么?我查看了预览版,我觉得它看起来不错(FF 3.6)。
  • media-owl.de/mobile 看看这个..上面的预览是我的PHP代码,但我需要Js来做同样的事情
  • 啊,我想不通。 entry.thumbnails 是空的,但如果您使用 entry.toSource(),它确实存在于 mediaGroups 中。您可以尝试另一个脚本...或者您可以使用 PHP 版本。这可能适用:code.google.com/p/google-ajax-apis/issues/detail?id=436

标签: php jquery xml feed


【解决方案1】:

您应该使用thumbnailurl

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

【讨论】:

    猜你喜欢
    • 2013-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-22
    • 2018-04-22
    • 1970-01-01
    相关资源
    最近更新 更多