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
Visitor (not verified)
Problem is solved by another module.
Wed, 2008/12/17 - 15:47I advise to use this module http://drupal.org/project/contemplate , instead to play with code.
Pages