Re: Re: Image Resize

Posts: 54
Joined: 08/08/2007

This method works fine for me:

$index = 0;
foreach ($node->field_image as $image) { // if your image field is named 'image'
  $index++;
  $filepath = $image['filepath'];
  $alt = $image['alt'];
  $title = $image['title'];
  if ($index == 1) {
    // first image large
    print '<a href="/'.$filepath.'" rel="'.$node->type.'-'.$node->nid.'" title="'.$alt.'" class="thickbox">'.theme('imagecache', 'large', $filepath, $alt, $title).'</a>';
  } else {
    // remaining images smaller
    print '<a href="/'.$filepath.'" rel="'.$node->type.'-'.$node->nid.'" title="'.$alt.'" class="thickbox">'.theme('imagecache', 'small', $filepath, $alt, $title).'</a>';
  }
}

You just need to set up two imagecache presets: one for the 'large' and one for the 'small' image.
Found it here.

Nifty Products Tutorial Part 1 By: mykz- (81 replies) Wed, 03/19/2008 - 20:04