Commit d928427a authored by frjo's avatar frjo
Browse files

Issue #1545342 by ifix: Part 2 of fix entity support in...

Issue #1545342 by ifix: Part 2 of fix entity support in theme_colorbox_image_formatter, it had node specifix stuff by mistake.
parent 7c27a27b
......@@ -498,7 +498,7 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
'auto' => t('Automatic'),
'title' => t('Title text'),
'alt' => t('Alt text'),
'node_title' => t('Node title'),
'node_title' => t('Entity title'),
'custom' => t('Custom (with tokens)'),
'none' => t('None'),
);
......@@ -524,7 +524,7 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#theme' => 'token_tree',
'#token_types' => array('node'),
'#token_types' => array($instance['entity_type']),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
......@@ -595,7 +595,7 @@ function colorbox_field_formatter_settings_summary($field, $instance, $view_mode
'auto' => t('Automatic'),
'title' => t('Title text'),
'alt' => t('Alt text'),
'node_title' => t('Node title'),
'node_title' => t('Entity title'),
'custom' => t('Custom (with tokens)'),
'none' => t('None'),
);
......
......@@ -36,6 +36,8 @@ function theme_colorbox_image_formatter($variables) {
$image['height'] = $item['height'];
}
$entity_title = entity_label($entity_type, $entity);
switch ($settings['colorbox_caption']) {
case 'auto':
// If the title is empty use alt or the node title in that order.
......@@ -45,8 +47,8 @@ function theme_colorbox_image_formatter($variables) {
elseif (!empty($image['alt'])) {
$caption = $image['alt'];
}
elseif (!empty($entity->title)) {
$caption = $entity->title;
elseif (!empty($entity_title)) {
$caption = $entity_title;
}
else {
$caption = '';
......@@ -59,7 +61,7 @@ function theme_colorbox_image_formatter($variables) {
$caption = $image['alt'];
break;
case 'node_title':
$caption = $entity->title;
$caption = $entity_title;
break;
case 'custom':
$caption = token_replace($settings['colorbox_caption_custom'], array($entity_type => $entity));
......@@ -76,16 +78,17 @@ function theme_colorbox_image_formatter($variables) {
}
// Build the gallery id.
$nid = !empty($entity->nid) ? $entity->nid : 'nid';
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$entity_id = !empty($id) ? $entity_type . '-' . $id : 'entity-id';
switch ($settings['colorbox_gallery']) {
case 'post':
$gallery_id = 'gallery-' . $nid;
$gallery_id = 'gallery-' . $entity_id;
break;
case 'page':
$gallery_id = 'gallery-all';
break;
case 'field_post':
$gallery_id = 'gallery-' . $nid . '-' . $field['field_name'];
$gallery_id = 'gallery-' . $entity_id . '-' . $field['field_name'];
break;
case 'field_page':
$gallery_id = 'gallery-' . $field['field_name'];
......
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