mmcglynn
mmcglynn

Reputation: 7662

Images in RSS feed

Whenever I see images in an RSS feed, they are embedded in CDATA, rather than surrounded by tags.

In my feed, I would like the images to show up without doing that.

Whether in the browser, or a feed reader (Bloglines) or through FeedBurner, the following structure does not show images, although it is valid RSS. Does anyone have experience with this?

<item>
<category>Viewbook</category>
<title>Widget</title>
<description>Learn more about our widgets.</description>
<link>http://www.widget.com/Default.aspx</link>
<image>
<url>http://www.widget.com/images/thumb.gif</url>
<title>Widget</title>
<link>http://www.widget.com/Default.aspx</link>
<description>Learn more about our widgets.</description>
</image>
</item> 

Upvotes: 31

Views: 85187

Answers (6)

user241244
user241244

Reputation:

You can use the media:content element (spec) within item.

Make sure you declare the MRSS (Media RSS) namespace (the xmlns:media attribute, below) for this element, if it is not declared for the whole RSS feed, as it won't validate otherwise. (E.g., out-of-the-box WordPress.)

    <media:content 
        xmlns:media="http://search.yahoo.com/mrss/" 
        url="http://www.widget.com/images/thumb.gif" 
        medium="image" 
        type="image/jpeg" 
        width="150" 
        height="150" />

This may or may not display as you'd like; you'd have to experiment. Embedding in content is in that way simpler, though this route helps with things like MailChimp integration (h/t this answer) or other custom solutions.

An example implementation for WordPress is in my answer here.

Upvotes: 10

Adam Pery
Adam Pery

Reputation: 2102

Use, e.g.:

<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />

Documentation here

Upvotes: 2

LucaPost
LucaPost

Reputation: 67

I believe you can use <media:content ....> items with good support by most rss readers, it is working flawlessly for us on mailchimp (rss to email newsletter).

See http://kb.mailchimp.com/article/how-can-i-format-the-image-content-in-my-rss-to-email-campaigns

EDIT: Here's a live link: https://blog.mailchimp.com/rss-to-email-enhancement-for-publishers/

Upvotes: 5

ViennaMike
ViennaMike

Reputation: 2337

For completeness: In RSS 2.0, you CAN have a single enclosure inside an item, which per the spec. can be for a single image. However I understand that support among feed aggregators varies. More typically this is used for things like podcasts. The RSS 2.0 standard states:

<enclosure> is an optional sub-element of <item>. 

It has three required attributes. url says where the enclosure is located, length says how big it is in bytes, and type says what its type is, a standard MIME type. The url must be an http url.

Note that you must include the size of the item, along with the URL and mime type.

However, as others indicated, including the picture(s) in CDATA is much more common.

Upvotes: 13

guerda
guerda

Reputation: 24049

On Colonol Sponsz' hint, I researched:

There's no image tag for items, only for the channel. So you have to do it via the CDATA tag.

Upvotes: 19

guerda
guerda

Reputation: 24049

It works with a seperate tag, as you said. The problem is the specification of version 2.0.

I know, there are feed reader that does supress images for bandwidth reasons.

Source: RSS specification 2.0 via Wikipedia

Upvotes: -4

Related Questions