[development] special filter behavior for teaser

Dave Cohen drupal at dave-cohen.com
Tue Feb 6 17:41:22 UTC 2007


Thanks for the feedback, everyone.

Since my interest is with inline images, placed with img_assist, in drupal 
4.7, I came up with this snippet which is working so far...

function custom_nodeapi(&$node, $op, $a3, $a4) {

  if ($op == 'view') {
    // For teasers, show thumbnails, not full images
    if ($a3) {
      //drupal_set_message("custom_nodeapi($op)" . dpr($node->teaser, 1));

      // modify the img tags inserted by img_assist
      $teaser = preg_replace('/<img src="([^"]*)\.([^\."]*)\.([^\."]*)" 
([^>]*) class="image ([^"]*)"([^>]*)>/',
                             
                             '<img src="$1.thumbnail.$3" $4 class="image 
thumbnail" />',
                             $node->teaser);
      //drupal_set_message("new teaser: " . dpr($teaser, 1));
      $node->teaser = $teaser;
      
    }
    
  }
}

Will post the same to the drupal forum.

-Dave


On Monday 05 February 2007 05:05, Dave Cohen wrote:
> I have a client using img_assist to add inline images.  They want
> thumbnails of images to appear in teaser views, and larger images to appear
> when the entire node body is shown.  Others have requested the same sort of
> thing here: http://drupal.org/node/107801.
>
> I was hoping to accomplish this by hacking the img_assist filter to change
> its behavior when a teaser is being generated as opposed to a full body. 
> But this information (whether a teaser is being generated or not) is not
> available in hook_filter.
>
> Is there any way for me to accomplish this?  I cannot think of a clean way
> so I wonder, should more parameters be passed to the check_markup and
> hook_filter functions?
>
> Apologies if this is a FAQ, and thanks for any advice,
>
> -Dave


More information about the development mailing list