$item['uri'], 'alt' => $item['alt'], 'title' => $item['title'], 'style_name' => $variables['image_style'], ); // If the title is empty use alt or the node title in that order. if (empty($item['title'])) { if (!empty($image['alt'])) { $image['title'] = $image['alt']; } else { $image['title'] = $node->title; } } // Shorten the title for the example styles or when title shortening is active. $style = variable_get('colorbox_style', 'default'); $trim_length = variable_get('colorbox_title_trim_length', 75); if (((strpos($style, 'colorbox/example') !== FALSE) || variable_get('colorbox_title_trim', 0)) && (drupal_strlen($item['title']) > $trim_length)) { $image['title'] = drupal_substr($item['title'], 0, $trim_length - 5) . '...'; } // Build the gallery id. $nid = $node->nid ? $node->nid : 'nid'; switch (variable_get('colorbox_imagefield_gallery', 1)) { case 0: $gallery_id = 'all'; break; case 1: $gallery_id = $nid; break; case 2: $gallery_id = $nid . '-' . $field['field_name']; break; case 3: $gallery_id = $nid . '-' . $field['fid']; break; } return theme('colorbox_imagefield', array('style_name' => $image['style_name'], 'path' => $image['path'], 'alt' => $image['alt'], 'title' => $image['title'], 'gid' => $gallery_id)); } /** * Returns HTML for an image using a specific Colorbox image style. * * @param $variables * An associative array containing: * - style_name: The name of the style to be used to alter the original image. * - path: The path of the image file relative to the Drupal files directory. * This function does not work with images outside the files directory nor * with remotely hosted images. * - alt: The alternative text for text-based browsers. * - title: The title text is displayed when the image is hovered in some * popular browsers. * - gid: Gallery id. * - attributes: Associative array of attributes to be placed in the img tag. * - getsize: If set to TRUE, the image's dimension are fetched and added as * width/height attributes. * * @ingroup themeable */ function theme_colorbox_imagefield($variables) { $image = theme('image_style', $variables); if ($style_name = variable_get('colorbox_imagecache_preset', 0)) { $link_path = image_style_url($style_name, $variables['path']); } else { $link_path = file_create_url($variables['path']); } $class = 'colorbox imagefield imagefield-imagelink'; return l($image, $link_path, array('html' => TRUE, 'attributes' => array('title' => $variables['title'], 'class' => $class, 'rel' => 'gallery-' . $variables['gid']))); }