function photobox_field_formatter_settings_form in PhotoboxPhotobox 7
Implements hook_field_formatter_settings_form().
File
- ./
photobox.module, line 51 - Main file for the Photobox module.
Code
function photobox_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$options = image_style_options(FALSE);
$element['photobox_content_image_style'] = array(
'#title' => t('Content image style'),
'#type' => 'select',
'#default_value' => $settings['photobox_content_image_style'],
'#empty_option' => t('None (original image)'),
'#options' => $options,
);
$element['photobox_content_image_style_first'] = array(
'#title' => t('Content image style for first image'),
'#type' => 'select',
'#default_value' => $settings['photobox_content_image_style_first'],
'#empty_option' => t('None (original image)'),
'#options' => $options,
);
$element['photobox_image_style'] = array(
'#title' => t('Photobox image style'),
'#type' => 'select',
'#default_value' => $settings['photobox_image_style'],
'#empty_option' => t('None (original image)'),
'#options' => $options,
);
$gallery = array(
'post' => t('Per post gallery'),
'page' => t('Per page gallery'),
'field_post' => t('Per field in post gallery'),
'field_page' => t('Per field in page gallery'),
'custom' => t('Custom'),
'none' => t('No gallery'),
);
$element['photobox_gallery'] = array(
'#title' => t('Gallery (image grouping)'),
'#type' => 'select',
'#default_value' => $settings['photobox_gallery'],
'#options' => $gallery,
'#description' => t('How Photobox should group the image galleries.'),
);
$element['photobox_gallery_custom'] = array(
'#title' => t('Custom gallery'),
'#type' => 'textfield',
'#maxlength' => 32,
'#default_value' => $settings['photobox_gallery_custom'],
'#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, hyphen and underscores.'),
'#element_validate' => array(
'photobox_gallery_custom_validate',
),
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][photobox_gallery]"]' => array(
'value' => 'custom',
),
),
),
);
$caption = array(
'auto' => t('Automatic'),
'title' => t('Title text'),
'alt' => t('Alt text'),
'content_title' => t('Content title'),
'custom' => t('Custom (with tokens)'),
'none' => t('None'),
);
$element['photobox_caption'] = array(
'#title' => t('Caption'),
'#type' => 'select',
'#default_value' => $settings['photobox_caption'],
'#options' => $caption,
'#description' => t('Automatic will use the first non-empty value of the title, the alt text and the content title.'),
);
$element['photobox_caption_custom'] = array(
'#title' => t('Custom caption'),
'#type' => 'textfield',
'#default_value' => $settings['photobox_caption_custom'],
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][photobox_caption]"]' => array(
'value' => 'custom',
),
),
),
);
// Allow users to hide or set a custom recursion limit.
// The module token_tweaks sets a global recursion limit that can not be bypassed.
if (module_exists('token')) {
$recursion_limit = min(variable_get('token_tree_recursion_limit', 3), variable_get('colorbox_token_recursion_limit', 3));
$element['photobox_token'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#theme' => 'token_tree',
'#token_types' => array(
$instance['entity_type'],
'file',
),
'#recursion_limit' => $recursion_limit,
'#dialog' => TRUE,
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][photobox_caption]"]' => array(
'value' => 'custom',
),
),
),
);
}
else {
$element['photobox_token'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#description' => '<strong class="error">' . t('For token support the <a href="@token_url">token module</a> must be installed.', array(
'@token_url' => 'http://drupal.org/project/token',
)) . '</strong>',
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][photobox_caption]"]' => array(
'value' => 'custom',
),
),
),
);
}
return $element;
}