Contents

Changing your RSS feed to include image node thumbnails

A site we worked on wanted to have the thumbnails for image nodes to be included in the RSS feed, so subcribers can get a preview of what the image is like before clicking.

So, using the 'rss item' $op to hook_nodeapi, we were able to do this in a relatively simple way, with no need to modify either Drupal's core nor the image module.

This article applies to Drupal 5.x, but may also be adapted to 4.7 and 6.x.

First, create a custom.info file under sites/all/modules or wherever you put your non-core modules.

Put the following in the file:

; $Id$
name = Custom
description = Customizations for this site 

Then, create a custom.module in the same directory, and put this in it.

<?php
function custom_nodeapi(&$node, $op, $teaser, $page) {
switch($op) {
case 'rss item':
$extra = NULL;
if ($node->type == 'image') {
// This is an image node, get the thumbnail
$extra = l(image_display($node, 'thumbnail'), 
"node/$node->nid", array(), NULL, NULL, FALSE, TRUE);
$node->teaser = $extra . $node->teaser;
$node->body .= $extra . $node->body;
return;
}
}
}

Visit Administer -> Build -> Modules and enable the custom module that you just created.

Now, RSS feeds will contain the image of the thumbnail.

Enjoy ...

I can't get this to work in Drupal 6.x

Can you help? Please advise.

body text repeated

This works for me except that, if there is any text in the body field, it is displayed twice in the feed item...both before and after the image. Any suggestions?

Trying to Do Something Similar...

... so far without much success, with the RSS items for nodes created by the FeedAPI module -- I want the RSS headline to link back to an item's original URL, not to the node that FeedAPI creates on my site.

I've posted a support request in the FeedAPI queue -- see
http://drupal.org/node/200434 -- but figured that whatever help I get there might be useful to those who find this post and are trying to tweak their RSS feeds in other ways.

I'm desperate

I'm desperate. I want to make more websites/blogs in drupal and this damn rss problem hold me to promote my rss. Also my email subscriptions are influenced by this damn problem. Can you help ? Please.....

Not working

I tried... but For Iexplorer 6 this is not working. A fix ?

Weird result

The feed now pulls an image from my site but it's my site logo/header image and not an image from the actual feed.

My Drupal install only accessible by direct linking so please add this to my url when you look.

unusualartists.com/lounge/aggregator/sources/1

Any ideas why this would happen?
Thanks
Jon