JFeed是否支持RSS图像? [英] Does JFeed support RSS images?

查看:58
本文介绍了JFeed是否支持RSS图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过JFeed的自述文件,无论如何它都没有提到获得RSS项目的图像:

I've had a look at JFeed's readme and it doesn't mention anyway to get to an RSS item's image:

* item.title
* item.link
* item.description
* item.updated
* item.id

有人知道解析这些图像的方法吗?

Does anyone know a way to parse these images?

推荐答案

简短回答"".

没有默认的 jFeed 支持RSS的图像"访问(或ATOM的"icon"/徽标"访问).

There is no default jFeed support for "image" access for RSS (or "icon"/"logo" access for ATOM).

那表示您可以始终扩展该库以支持提要图像.例如,在 jrss.js 中,您可以添加:

That said you could always extend the library to support feed images. For example in jrss.js you could add:

var image = jQuery('image', xml).eq(0);

this.image = new Object();
this.image.url = jQuery(image).find('url:first').text();
this.image.title = jQuery(image).find('title:first').text();
this.image.link = jQuery(image).find('link:first').text();

然后,您就可以从RSS提要中访问:

From an RSS feed you would then be able to access:

feed.image.url

但这仅有助于访问整个提要而不是单个项目的图形.

But this only facilitates accessing the graphic for the entire feed and not individual items.

要支持单个项目图像,您需要扩展jFeed以使其以某种方式支持属性.

To support individual item images you would need to extend jFeed to allow it to support attributes in some way.

例如,为了支持RSS 2.0附件,您可以将属性折叠为元素,这样便可以访问以下内容:

For example to support RSS 2.0 enclosures you could fold the attributes into elements, so you would be able to access something like:

item.enclosure.url

jrss.js 中,您可以添加以下内容:

In jrss.js you could add something like:

jQuery('item', xml).each( function() {

    var item = new JFeedItem();

    item.title = jQuery(this).find('title').eq(0).text();
    item.link = jQuery(this).find('link').eq(0).text();
    item.description = jQuery(this).find('description').eq(0).text();
    item.updated = jQuery(this).find('pubDate').eq(0).text();
    item.id = jQuery(this).find('guid').eq(0).text();

    item.enclosure = new Object();

    var enc = jQuery(this).find('enclosure');

    item.enclosure.url = jQuery(enc).attr('url');
    item.enclosure.length = jQuery(enc).attr('length');
    item.enclosure.type = jQuery(enc).attr('type');

    feed.items.push(item);
});

我很累,要继续做下去,你能告诉我吗? ;)

I'm tired and making this up as I go along, can you tell? ;)

这篇关于JFeed是否支持RSS图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆