Add an image to your RSS feed item

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.
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog