Log in

No account? Create an account

Previous Entry | Next Entry

The RSS specification allows you to have an <image> element in the header of your RSS feed.  A long time ago, if you used Wordpress, you'd have to edit the wp-rss.php file and be very careful when you upgraded to new releases, or your change could be lost.

But if you use a modern version of Wordpress, you should take advantage of the do_action('commentsrss2_head') hooks* in the feed-rss... .php files.

Here's what you'd do: Add the following code to your theme's functions.php file:

function add_my_rss_image()
echo '<image><title>', bloginfo_rss('name'), '</title>';
echo '<url>', bloginfo_rss('stylesheet_directory'), '/images/button.gif</url>';
echo '<link>', bloginfo_rss('url'), '</link>';
echo '<width>88</width><height>31</height>';
echo '<description>Description of your blog.</description></image>';


Take care to actually put an image file in the path specified, and adjust the width and height accordingly.

Et, voila! Now your feeds have images, and they're forwards compatible with future versions of Wordpress. Oh, did I say future versions of Wordpress? Excuse me, I have to:

svn sw http://svn.automattic.com/wordpress/tags/2.6/

Blam! Upgraded. Sweet.

* Also rss2_head and rss_head, just so I cover the appropriate Google terms.


( 17 comments — Leave a comment )
Aug. 10th, 2008 04:11 pm (UTC)
path of image


would probably be better than


so that you could use an images folder in the theme itself. Very helpful function, many thanks.
Aug. 10th, 2008 05:05 pm (UTC)
Re: path of image
Excellent suggestion, thanks!
Sep. 23rd, 2008 12:04 am (UTC)
well done
Perfect news!, man
Sep. 28th, 2008 12:03 pm (UTC)
well done
nice work, brother
Feb. 21st, 2009 06:12 pm (UTC)
What a good feature, many thanks. I am using Wordpress 2.6 and my rss feed have an image i specified to display.
Apr. 16th, 2009 10:15 pm (UTC)
I must have missed a step
I added this code to my functions.php but didn't get the desired result.

you said to:

"Take care to actually put an image file in the path specified, and adjust the width and height accordingly."

I'm not sure I know what you are saying here. There are images in every one of my articles. Am I supposed to do more than paste the code into the functions.php theme file?

I'd appreciate help for anyone.

Thank you,


Apr. 16th, 2009 10:32 pm (UTC)
Re: I must have missed a step
This tip doesn't have anything to do with images in your blog's articles. It only describes a WordPress-compatible way to provide an image to associate with the entire feed itself. (This is a rarely-used feature.)

Refer to the link at the top of this post, and examine only the section, "<image> sub-element of <channel>", to see what this is about.

If you get it, and can read XML, and understand the intent of the RSS schema, then this tip is for you. To verify you've done it correctly, you may want to cURL your feed's address and visually inspect the <channel> element. Most people don't concern themselves with this sort of thing.

Edited at 2009-04-16 10:33 pm (UTC)
May. 14th, 2009 07:54 am (UTC)
I use WP 2.7.1, and recently inserted the code into my functions.php, but no image show up in rss reader. No wonder: the lines defined in the function are simply not echoed in the source of my rss file, as if function did not executed at all at rss_head.
The same applies to 'blog icons' plugin, which I tried previously and works fine, except that image related lines in rss source are also absent. Curiously, plain favicon related code is echoed perfectly in index.php header.
I wonder, if rss_header hooks work in recent WP version just the same as used to?
May. 14th, 2009 02:16 pm (UTC)
Re: Compatible?
Yes, it works in WP 2.7.1, and even through redirects through feedburner! See my family blog for an example. View source to convince yourself of my WP version. (The feed actually redirects to http://feeds2.feedburner.com/dlma/my, which retained the image tag.)
May. 14th, 2009 09:13 pm (UTC)
Re: Compatible?
Well, I'm perplexed. After my first comment, I removed the code from functions.php (didn't want to left behind code which didn't seem to work), but I left 'blog icons' plugin (which is basically just the same, with an admin interface) installed. I know it sounds silly, but since then, the image related code "appeared" in all 3 feeds over time, first in the Atom and rss feeds, then at last in the rss2 feed too. Now it's all fine. Maybe it was some kind of a caching issue, or something like that.

(By the way, do you know how to use feed favicons with rss? Atom can specify it, but rss doesn't. Somehow, most rss feeds I'm subscribed to show their favicons in the feed reader. Maybe the reader automatically pick up the site's regular favicon?)

Charlie Brown
May. 18th, 2009 11:37 am (UTC)
I really like how you did this but unfortunately I can’t get it to work on my site. I think my code is a bit different and I’m not sure which bits are affecting the outcome. I’ll keep trying because I really like the result.nancy
Jul. 15th, 2009 01:31 pm (UTC)
Good idea
I did not know this! It's a good idea, Thanks for the code, I'll try it on my blog! voyance (http://www.alphamedium.fr)
Sep. 14th, 2009 02:21 pm (UTC)
Don't understand
I don't want to sound like an idiot but this is all very new to me. All I want is to add an image to my header.

This is my page: http://lchoafwb.org/naranonfl/

I would love to have a background image with our logo but I definitely want one to the left of the wording Nar-Anon Florida Region. Just to the left of that would be perfect.

Can someone please help me? Thanks.
Sep. 14th, 2009 03:48 pm (UTC)
Re: Don't understand
The subject of this post has nothing to do with any of the images displayed at your website. It's only about putting an image in your blog's RSS feed's header, which is a detail that most people won't worry about.

When it comes to customizing your blog's "header" the way you want, that's customizing your blog's theme's header. You'll have to learn about customizing themes. You may find help with that over at Wordpress.org. Good luck!
Dec. 15th, 2009 01:38 pm (UTC)
Alt text
Hello David,

Thank you very much for the article!

Do you happen to know how does one add the alternate text for the image included in the RSS feed?


Feb. 13th, 2010 02:48 pm (UTC)
this might be easier for some
Just a hint for some: an easier way to get an image in your feed's header is to burn your feed with feedburner (use the help provided there), and use THAT service to do all sorts of things with your feed - a.o. display an image. No need to get into functions.php.
Feb. 22nd, 2011 06:46 am (UTC)
Synthesis Of Topiramate
Topiramate Brand Name (http://www.box.net/shared/vudyhcjpf3)
Topiramate Alcohol (http://www.box.net/shared/fokta2vl5j)
Epilepsy is diagnosed when a person has recurring seizures, ... want that you can treat epilepsy is to be honest and to take your medications as prescribed. ...
Side Effects Of Topiramate (http://www.box.net/shared/n3qsd2cqus)
10 Dec 2010 ... Epileptic seizure prescription medication. Offers prescribing information and information for professionals.TOPAMAX Side Effects - Can TOPAMAX Help Me? - Full Prescribing Info - FAQs
13 Feb 2011 ... Consumer information about the medication TOPIRAMATE - ORAL (Topamax), includes side effects, drug interactions, recommended dosages, ...
Topiramate No Prescription (http://www.box.net/shared/95ie5efukn)
Klonopin online a prescription medication that is commonly used to treat Epilepsy and panic disorders. ... Epilepsy (Seizure disorders) Panic Disorders ...
31 Dec 2010 ... People with seizures that begin with a warning may be able to breathe .... when compared to the standard prescription medications which are ... - Cached
19 Dec 2010 ... Top offer where to buy cheap benicar online without prescription. Copyright © 2010 Benicar Online Pharmacy. ... cozaar benicar high blood pressure medication ... benicar htc and epileptic seizures benicar tablature ...
Before you know the various prescription drugs available to treat seizures you ... Epilepsy or dog seizure cannot be cured but if the right medication is ... - Cached - Similar
Phentermine And Topiramate Emotional Side Effects (http://www.box.net/shared/67syjpe0vh)
Discount Topiramate (http://www.box.net/shared/4zb5hyiia6)
Topiramate In Migraine (http://www.box.net/shared/k06qv0lonq)
Phentermine Topiramate (http://www.box.net/shared/pc9i5n137g)
Topiramate Alcohol Dependence (http://www.box.net/shared/8p6qugs7aq)
( 17 comments — Leave a comment )