1. function theme_imagefield_gallery_lightbox2($images = array(), $node) {
  2.   $output = '';
  3.   $count = count($images);
  4.   $var = variable_get('imagefield_gallery', array());
  5.   if ($count) {
  6.     $i = 0;
  7.     if (!module_exists('lightbox2')) {
  8.       $js_settings = array(
  9.         'use_alt_layout' =>  false,
  10.         'disable_zoom' => false,
  11.         'force_show_nav' => false,
  12.         'group_images' => TRUE,
  13.         'disable_for_gallery_lists' => TRUE,
  14.         'node_link_text' => check_plain(t('View Image Details')),
  15.         'image_count' => check_plain(t('Image !current of !total')),
  16.         'lite_press_x_close' => t('press !x to close', array('!x' => '<a href="#" onclick="hideLightbox(); return false;"><kbd>x</kbd></a>')),
  17.       );
  18.       drupal_add_js(array('lightbox2' => $js_settings), 'setting');
  19.       drupal_add_js(drupal_get_path('module', 'imagefield_gallery_lightbox2') .'/js/lightbox.js');
  20.       drupal_add_css(drupal_get_path('module', 'imagefield_gallery_lightbox2') .'/css/lightbox.css');
  21.     }
  22.  
  23.     $output .= '<span class="gallery_text">'. t('Click the images below for bigger versions:') .'</span>';
  24.     $output .= '<div class="'. $node->type .'_gallery_box">';
  25.     while ($i < $count) {
  26.  
  27.       $thumbnail = $var[$node->type]['images']['thumbnail'];
  28.       $preview = $var[$node->type]['images']['preview'];
  29.       if ($images[$i]['filepath']) {
  30.         $file['filepath'] = $images[$i]['filepath'];
  31.         $imagecache_path = base_path() . file_directory_path() .'/imagecache/'. $preview .'/'. $file['filepath'];
  32.         $output .= '<div class="'. $node->type .'_image_field_thumbnail">';
  33.         $output .= '<a href="'. $imagecache_path .'" rel="lightbox['. $node->nid .']">';
  34.         $output .= theme('imagecache', $thumbnail, $file['filepath']);
  35.         $output .= '</a>';
  36.         $output .= '</div>';
  37.       }
  38.       $i++;
  39.     }
  40.  
  41.   $output .= '<div class="clear_both"></div>';
  42.   $output .= '</div>';
  43.   }
  44.   return $output;
  45. }