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

Comments

Pages

Is your Drupal or Backdrop CMS site slow?
Is it suffering from server resources shortages?
Is it experiencing outages?
Contact us for Drupal or Backdrop CMS Performance Optimization and Tuning Consulting