function flexslider_picture_form_ctools_export_ui_edit_item_form_alter in Picture 7.2
Same name and namespace in other branches
- 7 flexslider_picture/flexslider_picture.module \flexslider_picture_form_ctools_export_ui_edit_item_form_alter()
Implements hook_form_FORM_ID_alter().
File
- flexslider_picture/
flexslider_picture.module, line 94 - Picture formatter with flexslider support.
Code
function flexslider_picture_form_ctools_export_ui_edit_item_form_alter(&$form, &$form_state) {
if ($form_state['plugin']['schema'] == 'flexslider_optionset') {
$form['image_style']['#tree'] = TRUE;
$form['image_style']['#weight'] = 0;
$form['title']['#weight'] = -1;
$form['image_style']['imagestyle_type'] = array(
'#type' => 'radios',
'#title' => t('Image type'),
'#description' => t('Choosing picture mapping will give you a truly responsive slider.
Flexslider is responsive because it will resize the images for smaller screens, but it will still load the large image.
With picture mappings, a smaller image will be loaded for smaller screens (and thus less data transfer).'),
'#options' => array(
'image_style' => t('Image Style'),
'picture_mapping' => t('Picture Mapping'),
),
'#weight' => -2,
'#default_value' => isset($form_state['item']->imagestyle_type) && !empty($form_state['item']->imagestyle_type) ? $form_state['item']->imagestyle_type : 'image_style',
);
$options = picture_get_mapping_options();
$form['image_style']['mapping'] = array(
'#title' => t('Normal picuture mapping'),
'#states' => array(
'visible' => array(
':input[name="image_style[imagestyle_type]"]' => array(
'value' => 'picture_mapping',
),
),
),
'#weight' => -1,
);
if (!empty($options)) {
$form['image_style']['mapping'] += array(
'#type' => 'select',
'#description' => t('Picture mapping for the main stage images.'),
'#options' => $options,
'#default_value' => !empty($form_state['item']->mapping) ? $form_state['item']->mapping : '',
);
}
else {
$form['image_style']['mapping'] += array(
'#type' => 'item',
'#markup' => t("There're no picture mappings defined, you'll have to !create them first.", array(
'!create' => l(t('create'), 'admin/config/media/picture'),
)),
);
}
$image_styles = image_style_options(FALSE);
$form['image_style']['fallback'] = array(
'#title' => t('Fallback image style'),
'#description' => t('The fallback image style to use'),
'#type' => 'select',
'#empty_option' => t('Automatic'),
'#options' => $image_styles + array(
PICTURE_EMPTY_IMAGE => t('Empty image'),
PICTURE_ORIGINAL_IMAGE => t('Original image'),
),
'#states' => array(
'visible' => array(
':input[name="image_style[imagestyle_type]"]' => array(
'value' => 'picture_mapping',
),
),
),
'#default_value' => !empty($form_state['item']->fallback) ? $form_state['item']->fallback : '',
);
// Colorbox support.
$form['image_style']['colorboxEnabled'] = array(
'#title' => t('Enable colorbox'),
'#type' => 'checkbox',
'#default_value' => !empty($form_state['item']->options['colorboxEnabled']) ? $form_state['item']->options['colorboxEnabled'] : '',
);
$form['image_style']['colorboxImageStyle'] = array(
'#title' => t('Colorbox group'),
'#type' => 'select',
'#default_value' => !empty($form_state['item']->options['colorboxImageStyle']) ? $form_state['item']->options['colorboxImageStyle'] : '',
'#required' => FALSE,
'#options' => $options,
'#states' => array(
'visible' => array(
':input[name$="image_style[colorboxEnabled]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['image_style']['colorboxFallbackImageStyle'] = array(
'#title' => t('Colorbox fallback image style'),
'#type' => 'select',
'#default_value' => !empty($form_state['item']->options['colorboxFallbackImageStyle']) ? $form_state['item']->options['colorboxFallbackImageStyle'] : '',
'#required' => FALSE,
'#empty_option' => t('Automatic'),
'#options' => $image_styles + array(
PICTURE_EMPTY_IMAGE => t('Empty image'),
PICTURE_ORIGINAL_IMAGE => t('Original image'),
),
'#states' => array(
'visible' => array(
':input[name$="image_style[colorboxEnabled]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['#submit'][] = '_flexslider_picture_ctools_export_ui_edit_item_form_submit';
}
}