function galleria_field_formatter_settings_summary in Galleria 7
Implements hook_field_formatter_settings_summary().
Displays the summary of the set options of a Galleria formatted image field
File
- ./
galleria.module, line 451 - A light-weight, customizable image gallery plugin for Drupal based on jQuery
Code
function galleria_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = array();
// Optionset
$optionset = t('Default settings');
if (!empty($settings['optionset'])) {
$o = galleria_optionset_load($settings['optionset']);
if ($o !== NULL) {
$optionset = $o->title;
}
}
$summary[] = t('Option set: %optionset', array(
'%optionset' => $optionset,
));
// Summary for file fields.
if ($field['type'] == 'file') {
// Prepare options list.
if (!empty($settings['alt_field']) || !empty($settings['title_field'])) {
$bundles = field_info_instances('file');
// Determine if there are additional fields on the image instance.
if (isset($bundles['image']) && !empty($bundles['image'])) {
$options = array(
'' => t('None'),
);
foreach ($bundles['image'] as $field_name => $field_details) {
$options[$field_name] = $field_details['label'];
}
}
}
if (!empty($settings['alt_field'])) {
$summary[] = t('Alt field: @title', array(
'@title' => $options[$settings['alt_field']],
));
}
if (!empty($settings['title_field'])) {
$summary[] = t('Title field: @title', array(
'@title' => $options[$settings['title_field']],
));
}
}
// For node_reference fields: Referenced image fields
if ($field['type'] == 'node_reference') {
$referenced_fields = array();
foreach ($settings['referenced_fields'] as $node_type => $fields) {
$fields = array_keys(array_filter($fields));
if (!empty($fields)) {
foreach ($fields as &$field) {
$field_info = field_info_instance('node', $field, $node_type);
$field = $field_info['label'];
}
$referenced_fields[] = node_type_get_name($node_type) . ': ' . implode(', ', $fields);
}
}
$referenced_fields = empty($referenced_fields) ? t('All') : implode('; ', $referenced_fields);
$summary[] = t('Referenced image fields: %fields', array(
'%fields' => $referenced_fields,
));
}
return '<p>' . implode("</p>\n<p>", $summary) . '</p>';
}