Add an image to your RSS feed item

0 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.

01.<?xml version="1.0" encoding="utf-8"?>  
02.<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">  
03.    <channel>  
04.        <title>ThatAwesomeShirt! Latest Shirts</title>  
05.        <link>http://www.thatawesomeshirt.com/<;/link>  
06.        ...  
07.        <item>  
08.            <title>AWESOMENESS</title>  
09.            <link>http://www.thatawesomeshirt.com/shirt/209/awesomeness<;/link>  
10.            ...  
11.            <media:thumbnail url='http://www.thatawesomeshirt.com/images/get/252/shirt_thumbnail' height='75' width='75' />  
12.        </item>  
13.        <item>  
14.            <title>Quit Work, Be A Ninja</title>  
15.            <link>http://www.thatawesomeshirt.com/shirt/208/quit_work_be_a_ninja<;/link>  
16.            ...  
17.            <strong><media:thumbnail url='http://www.thatawesomeshirt.com/images/get/251/shirt_thumbnail' height='75' width='75' /></strong>  
18.        </item>  
19.        ...  
20.    </channel>  
21.</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