Drupal 6 themed images with ImageCache and Thickbox or Lightbox

This is mostly because I can't remember how to do this all the time.

The ImageCache preset is 'vpthumb' in this case.

// theme('imagecache', $preset, $filepath, $alt, $title,  $attributes);
$thumbnail = theme('imagecache',
  'vpthumb',
  $image['filepath'],
  $image['data']['description'],
  $image['data']['description']
);

Figuring out which popup box is available to the site

  $classes = '';
  $rel = '';
  if (module_exists('lightbox2')) {
    $classes = 'lightbox';
    $rel = 'lightbox[simple-gallery]';
  } else if (module_exists('thickbox')) {
    $classes = 'thickbox';
    $rel = 'simple-gallery';
  }

Finally, linking them all in

$output .= l($thumbnail,
  $image['filepath'],
  array(
    'attributes' => array(
      'class' => $classes,
      'rel' => $rel,
      'title' => $image['data']['description']
    ),
    'html' => TRUE,
  )
);