function photoswipe_field_formatter_settings_form in PhotoSwipe 7.2
Same name and namespace in other branches
- 7 photoswipe.module \photoswipe_field_formatter_settings_form()
Implements hook_field_formatter_settings_form().
File
- ./
photoswipe.module, line 165 - Photswipe integration with Drupal module.
Code
function photoswipe_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$image_styles = image_style_options(FALSE);
$image_styles_hide = $image_styles;
$image_styles_hide['hide'] = t('Hide (do not display image)');
$element['photoswipe_node_style_first'] = array(
'#title' => t('Node image style for first image'),
'#type' => 'select',
'#default_value' => $settings['photoswipe_node_style_first'],
'#empty_option' => t('No special style.'),
'#options' => $image_styles_hide,
'#description' => t('Image style to use in the content for the first image.'),
);
$element['photoswipe_node_style'] = array(
'#title' => t('Node image style'),
'#type' => 'select',
'#default_value' => $settings['photoswipe_node_style'],
'#empty_option' => t('None (original image)'),
'#options' => $image_styles_hide,
'#description' => t('Image style to use in the node.'),
);
$element['photoswipe_image_style'] = array(
'#title' => t('Photoswipe image style'),
'#type' => 'select',
'#default_value' => $settings['photoswipe_image_style'],
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#description' => t('Image style to use in the Photoswipe.'),
);
// Set our caption options
$caption_options = array(
'alt' => t('Image Alt Tag'),
'title' => t('Image Title Tag'),
'node_title' => t('Node Title'),
);
// Add the other node fields as options
foreach ($form['#fields'] as $node_field) {
if ($node_field != $instance['field_name']) {
$caption_options[$node_field] = $node_field;
}
}
$element['photoswipe_caption'] = array(
'#title' => t('Photoswipe image caption'),
'#type' => 'select',
'#default_value' => $settings['photoswipe_caption'] ? $settings['photoswipe_caption'] : 'alt',
'#options' => $caption_options,
'#description' => t('Field that should be used for the caption.'),
);
// Add the current view mode so we can control the view mode for node fields.
$element['photoswipe_view_mode'] = array(
'#type' => 'hidden',
'#value' => $view_mode,
);
return $element;
}