function theme_imagefield_image_imagecache_lightbox2 in Lightbox2 5.2
Same name and namespace in other branches
- 5 lightbox2.module \theme_imagefield_image_imagecache_lightbox2()
- 6 lightbox2.formatter.inc \theme_imagefield_image_imagecache_lightbox2()
Generate the HTML output for imagefield + imagecache images so they can be opened in a lightbox by clicking on the image on the node page or in a view.
Parameters
$view_preset: The imagecache preset to be displayed on the node or in the view.
$field: The field the action is being performed on.
$item: An array, keyed by column, of the data stored for this item in this field.
$node: The node object.
$rel: The type of lightbox to open: lightbox, lightshow or lightframe.
1 theme call to theme_imagefield_image_imagecache_lightbox2()
- lightbox2_imagefield_image_imagecache in ./
lightbox2.module - Function to set up the data needed for theme_imagefield_image_imagecache_lightbox2().
File
- ./
lightbox2.module, line 1876 - Enables the use of lightbox2 which places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.
Code
function theme_imagefield_image_imagecache_lightbox2($view_preset, $field, $item, $node, $rel = 'lightbox') {
// Can't show current node page in a lightframe on the node page.
// Switch instead to show it in a lightbox.
if ($rel == 'lightframe' && arg(0) == 'node' && arg(1) == $node->nid) {
$rel = 'lightbox';
$item['lightbox_preset'] = 'original';
}
$orig_rel = $rel;
// Set up the caption.
$node_link = '';
$attributes = array();
if (!empty($item['nid'])) {
$target = variable_get('lightbox2_node_link_target', FALSE);
if (!empty($target)) {
$attributes = array(
'target' => $target,
);
}
$node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
if (!empty($node_link_text)) {
$node_link .= '<br /><br />' . l($node_link_text, 'node/' . $item['nid'], $attributes);
}
}
if ($orig_rel == 'lightframe') {
$frame_width = variable_get('lightbox2_default_frame_width', 600);
$frame_height = variable_get('lightbox2_default_frame_height', 400);
$frame_size = 'width:' . $frame_width . 'px; height:' . $frame_height . 'px;';
$rel = preg_replace('/\\]$/', "|{$frame_size}]", $rel);
}
$image_title = $item['description'];
$image_title = !empty($image_title) ? $image_title : $item['title'];
$image_title = !empty($image_title) ? $image_title : $item['alt'];
if (variable_get('lightbox2_imagefield_use_node_title', FALSE)) {
$node = node_load($node->nid);
$image_title = $node->title;
}
$caption = $image_title . $node_link;
// Set up the rel attribute.
$imagefield_grouping = variable_get('lightbox2_imagefield_group_node_id', 1);
if ($imagefield_grouping == 1) {
$rel = $rel . '[' . $field['field_name'] . '][' . $caption . ']';
}
elseif ($imagefield_grouping == 2 && !empty($item['nid'])) {
$rel = $rel . '[' . $item['nid'] . '][' . $caption . ']';
}
elseif ($imagefield_grouping == 3 && !empty($item['nid'])) {
$rel = $rel . '[' . $field['field_name'] . $item['nid'] . '][' . $caption . ']';
}
else {
$rel = $rel . '[][' . $caption . ']';
}
$link_attributes = array(
'rel' => $rel,
);
if ($view_preset == 'original') {
$image = theme('lightbox2_image', $item['filepath'], $item['alt'], $item['title'], $attributes);
}
else {
$image = theme('imagecache', $view_preset, $item['filepath'], $item['alt'], $item['title'], $attributes);
}
if ($item['lightbox_preset'] == 'node') {
$output = l($image, 'node/' . $node->nid . '/lightbox2', $link_attributes, NULL, NULL, FALSE, TRUE);
}
elseif ($item['lightbox_preset'] == 'original') {
$output = l($image, file_create_url($item['filepath']), $link_attributes, NULL, NULL, FALSE, TRUE);
}
else {
$output = l($image, lightbox2_imagecache_create_url($item['lightbox_preset'], $item['filepath']), $link_attributes, NULL, NULL, FALSE, TRUE);
}
return $output;
}