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() { ...@@ -39,7 +39,9 @@ function colorbox_theme() {
'colorbox_image_formatter' => array( 'colorbox_image_formatter' => array(
'variables' => array( 'variables' => array(
'item' => NULL, 'item' => NULL,
'node' => NULL, 'entity_type' => NULL,
'entity' => NULL,
'node' => NULL, // Left for legacy support.
'field' => array(), 'field' => array(),
'display_settings' => array(), 'display_settings' => array(),
), ),
...@@ -614,7 +616,9 @@ function colorbox_field_formatter_view($entity_type, $entity, $field, $instance, ...@@ -614,7 +616,9 @@ function colorbox_field_formatter_view($entity_type, $entity, $field, $instance,
$element[$delta] = array( $element[$delta] = array(
'#theme' => 'colorbox_image_formatter', '#theme' => 'colorbox_image_formatter',
'#item' => $item, '#item' => $item,
'#node' => $entity, '#entity_type' => $entity_type,
'#entity' => $entity,
'#node' => $entity, // Left for legacy support.
'#field' => $field, '#field' => $field,
'#display_settings' => $display['settings'], '#display_settings' => $display['settings'],
); );
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
*/ */
function theme_colorbox_image_formatter($variables) { function theme_colorbox_image_formatter($variables) {
$item = $variables['item']; $item = $variables['item'];
$node = $variables['node']; $entity_type = $variables['entity_type'];
$entity = $variables['entity'];
$field = $variables['field']; $field = $variables['field'];
$settings = $variables['display_settings']; $settings = $variables['display_settings'];
...@@ -44,8 +45,8 @@ function theme_colorbox_image_formatter($variables) { ...@@ -44,8 +45,8 @@ function theme_colorbox_image_formatter($variables) {
elseif (!empty($image['alt'])) { elseif (!empty($image['alt'])) {
$caption = $image['alt']; $caption = $image['alt'];
} }
elseif (!empty($node->title)) { elseif (!empty($entity->title)) {
$caption = $node->title; $caption = $entity->title;
} }
else { else {
$caption = ''; $caption = '';
...@@ -58,10 +59,10 @@ function theme_colorbox_image_formatter($variables) { ...@@ -58,10 +59,10 @@ function theme_colorbox_image_formatter($variables) {
$caption = $image['alt']; $caption = $image['alt'];
break; break;
case 'node_title': case 'node_title':
$caption = $node->title; $caption = $entity->title;
break; break;
case 'custom': case 'custom':
$caption = token_replace($settings['colorbox_caption_custom'], array('node' => $node)); $caption = token_replace($settings['colorbox_caption_custom'], array($entity_type => $entity));
break; break;
default: default:
$caption = ''; $caption = '';
...@@ -75,7 +76,7 @@ function theme_colorbox_image_formatter($variables) { ...@@ -75,7 +76,7 @@ function theme_colorbox_image_formatter($variables) {
} }
// Build the gallery id. // Build the gallery id.
$nid = !empty($node->nid) ? $node->nid : 'nid'; $nid = !empty($entity->nid) ? $entity->nid : 'nid';
switch ($settings['colorbox_gallery']) { switch ($settings['colorbox_gallery']) {
case 'post': case 'post':
$gallery_id = 'gallery-' . $nid; $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