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:
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:
Blam! Upgraded. Sweet.
* Also rss2_head and rss_head, just so I cover the appropriate Google terms.
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>';
}
add_action('rss2_head','add_my_rss_image');
add_action('rss_head','add_my_rss_image');
add_action('commentsrss2_head','add_my_rss_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.


Comments
bloginfo_rss('stylesheet_directory')
would probably be better than
bloginfo_rss('url')
so that you could use an images folder in the theme itself. Very helpful function, many thanks.
-Cars
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,
Sharon
smkyle1@yahoo.com
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)
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?
(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?)
greetz!
Charlie Brown
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.
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!
-----------------
nuoc hoa | Nuoc hoa nam | Nuoc hoa nu
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?
Cheers,
Nik