function theme_lightbox2_emimage in Lightbox2 6
Generate the HTML output to open embedded cck images in a lightbox.
Parameters
$field: The CCK field the action is being performed on.
$item: An array, keyed by column, of the data stored for this item in this field.
$formatter: The formatter to use for the field.
$node: The node object.
$args: Args may override internal processes: caption, rel_grouping.
Return value
Themed embedded media field image and link.
File
- ./
lightbox2.formatter.inc, line 382 - Lightbox2 formatter hooks and callbacks.
Code
function theme_lightbox2_emimage($field, $item, $formatter, $node, $args = array()) {
$lightbox_type = $field['lightbox_type'];
if ($item['value'] && $item['provider']) {
$rel = 'lightbox';
if ($lightbox_type == 'lightshow2') {
$rel = 'lightshow';
}
elseif ($lightbox_type == 'lightframe2') {
$rel = 'lightframe';
}
if ($rel == 'lightframe' && arg(0) == 'node' && arg(1) == $node->nid) {
$rel = 'lightbox';
}
$orig_rel = $rel;
$code = $item['value'];
$width = $field['widget']['thumbnail_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['thumbnail_width'];
$height = $field['widget']['thumbnail_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['thumbnail_height'];
$link = $field['widget']['thumbnail_link'] ? $field['widget']['thumbnail_link'] : variable_get('emimage_default_thumbnail_link', EMIMAGE_DEFAULT_THUMBNAIL_LINK);
if ($link == EMIMAGE_LINK_CONTENT) {
$link = 'node/' . $node->nid;
}
elseif ($link == EMIMAGE_LINK_PROVIDER) {
$link = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'embedded_link', $code, $item['data']);
}
else {
$link = NULL;
}
$attributes = array();
$attributes['id'] = 'lightbox2-node-link-text';
if ($width) {
$attributes['width'] = $width;
}
if ($height) {
$attributes['height'] = $height;
}
$target = variable_get('lightbox2_node_link_target', FALSE);
if (!empty($target)) {
$attributes['target'] = $target;
}
// Set up the title.
$title = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_title', $code, $item['data']);
// Set up the caption.
$node_link = '';
$node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
if (!empty($node_link_text) && !empty($link)) {
$node_link = '<br /><br />' . l($node_link_text, $link, array(
'attributes' => $attributes,
));
}
// @TODO original download link possible with emfield?
$caption = $title . $node_link;
if (isset($args['caption'])) {
$caption = $args['caption'];
// Override caption.
}
// Set up url and image.
$url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $width, $height, "emimage", $field, $item, $node);
$image = theme('image', $url, $title, $title, $attributes, FALSE);
// Set up full rel attribute.
$image_grouping = variable_get('lightbox2_emimage_group_node_id', 1);
if ($image_grouping == 1) {
$full_rel = $rel . '[' . $field['field_name'] . '][' . $caption . ']';
}
elseif ($image_grouping == 2 && !empty($node->nid)) {
$full_rel = $rel . '[' . $node->nid . '][' . $caption . ']';
}
elseif ($image_grouping == 3 && !empty($node->nid)) {
$full_rel = $rel . '[' . $field['field_name'] . '_' . $node->nid . '][' . $caption . ']';
}
elseif (isset($args['rel_grouping'])) {
$full_rel = $rel . '[' . $args['rel_grouping'] . '][' . $caption . ']';
}
else {
$rel = $full_rel . '[][' . $caption . ']';
}
if ($orig_rel != 'lightframe') {
$link_attributes = array(
'rel' => $full_rel,
);
$full_width = $field['widget']['full_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['full_width'];
$full_height = $field['widget']['full_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['full_height'];
$full_image_url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $full_width, $full_height, "emimage", $field, $item, $node);
$output = l($image, $full_image_url, array(
'attributes' => $link_attributes,
'html' => TRUE,
));
}
else {
$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;';
$full_rel = preg_replace('/\\]\\[/', "|{$frame_size}][", $full_rel);
$link_attributes = array(
'rel' => $full_rel,
);
$output = l($image, $link . '/lightbox2', array(
'attributes' => $link_attributes,
'html' => TRUE,
));
}
}
return $output;
}