Add an image to your RSS feed item

3 comments

It was surprisingly easy to get images into the RSS feed.

All you have to do is add the following attributes and your feeds should be image ready.

  • xmlns:media="http://search.yahoo.com/mrss/" in the XML tag.
  • <media:thumbnail url='http://link' height='x' width='y' /> element in the item.

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        <title>ThatAwesomeShirt! Latest Shirts</title>
        <link>http://www.thatawesomeshirt.com/</link>
        ...
        <item>
            <title>AWESOMENESS</title>
            <link>http://www.thatawesomeshirt.com/shirt/209/awesomeness</link>
            ...
            <media:thumbnail url='http://www.thatawesomeshirt.com/images/get/252/shirt_thumbnail' height='75' width='75' />
        </item>
        <item>
            <title>Quit Work, Be A Ninja</title>
            <link>http://www.thatawesomeshirt.com/shirt/208/quit_work_be_a_ninja</link>
            ...
            <media:thumbnail url='http://www.thatawesomeshirt.com/images/get/251/shirt_thumbnail' height='75' width='75' />
        </item>
        ...
    </channel>
</rss>

Now, 2 things to make sure of:

  • Make sure you're using RSS 2.0 onwards.
  • The URL for the image must be an absolute URL.

Related Posts

3 comments:

  1. Hi, I am trying to make it work and none of the thumbnails will display in FF12 or IE8.0. This sounded neat, simple and promising. I'd really like to render the images. Could you please help?

    ReplyDelete
  2. Hey there,

    I haven't actually seen any browsers support the thumbnail attribute unless it was read by a 3rd party renderer.

    If you find any feeds which work on a browser, please let me know!

    ReplyDelete
  3. Add this into your RSS 2.0 xml file for each thumbnail image, in the section:

    [enclosure url="http://www.domain.com/news/image-photo-thumbnail.jpg" length="image-size-number" type="image/jpeg"]

    ReplyDelete

Leave your thoughts ...
---
If you are having trouble with copy/pasting in comments, you need to sign in or click 'Preview'. For more information about this Firefox bug, see here.

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog