Commit 7c27a27b authored by frjo's avatar frjo
Browse files

Issue #1545342 by ifix: Fix entity support in theme_colorbox_image_formatter,...

Issue #1545342 by ifix: Fix entity support in theme_colorbox_image_formatter, it had node specifix stuff by mistake.
parent 831642f4
......@@ -39,7 +39,9 @@ function colorbox_theme() {
'colorbox_image_formatter' => array(
'variables' => array(
'item' => NULL,
'node' => NULL,
'entity_type' => NULL,
'entity' => NULL,
'node' => NULL, // Left for legacy support.
'field' => array(),
'display_settings' => array(),
),
......@@ -614,7 +616,9 @@ function colorbox_field_formatter_view($entity_type, $entity, $field, $instance,
$element[$delta] = array(
'#theme' => 'colorbox_image_formatter',
'#item' => $item,
'#node' => $entity,
'#entity_type' => $entity_type,
'#entity' => $entity,
'#node' => $entity, // Left for legacy support.
'#field' => $field,
'#display_settings' => $display['settings'],
);
......
......@@ -19,7 +19,8 @@
*/
function theme_colorbox_image_formatter($variables) {
$item = $variables['item'];
$node = $variables['node'];
$entity_type = $variables['entity_type'];
$entity = $variables['entity'];
$field = $variables['field'];
$settings = $variables['display_settings'];
......@@ -44,8 +45,8 @@ function theme_colorbox_image_formatter($variables) {
elseif (!empty($image['alt'])) {
$caption = $image['alt'];
}
elseif (!empty($node->title)) {
$caption = $node->title;
elseif (!empty($entity->title)) {
$caption = $entity->title;
}
else {
$caption = '';
......@@ -58,10 +59,10 @@ function theme_colorbox_image_formatter($variables) {
$caption = $image['alt'];
break;
case 'node_title':
$caption = $node->title;
$caption = $entity->title;
break;
case 'custom':
$caption = token_replace($settings['colorbox_caption_custom'], array('node' => $node));
$caption = token_replace($settings['colorbox_caption_custom'], array($entity_type => $entity));
break;
default:
$caption = '';
......@@ -75,7 +76,7 @@ function theme_colorbox_image_formatter($variables) {
}
// Build the gallery id.
$nid = !empty($node->nid) ? $node->nid : 'nid';
$nid = !empty($entity->nid) ? $entity->nid : 'nid';
switch ($settings['colorbox_gallery']) {
case 'post':
$gallery_id = 'gallery-' . $nid;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment