function manualcrop_field_widget_settings_form_alter in Manual Crop 7
Alters the existing field widget settings form elements.
Parameters
$form: Instance form elements array.
1 call to manualcrop_field_widget_settings_form_alter()
File
- ./
manualcrop.admin.inc, line 763 - Admin functionality for the Manual Crop module.
Code
function manualcrop_field_widget_settings_form_alter(&$form, $settings) {
if ($form['widget']['type']['#value'] == 'image_image' && isset($settings['preview_image_style'])) {
// Disable the image field preview if the thumblist option is enabled.
$form['widget']['settings']['preview_image_style']['#states'] = array(
'disabled' => array(
'input[name="instance[widget][settings][manualcrop_enable]"]' => array(
'checked' => TRUE,
),
'input[name="instance[widget][settings][manualcrop_thumblist]"]' => array(
'checked' => TRUE,
),
),
);
}
if (module_exists('insert') && isset($form['settings']['insert'])) {
// Get the reference to the insert fieldset.
$insert =& $form['settings']['insert'];
// Make sure the insert checkbox stays on top.
$insert['insert']['#weight'] = -2;
// Add an option to exclude image styles without a Manual Crop effect.
$insert['manualcrop_filter_insert'] = array(
'#type' => 'checkbox',
'#title' => t('Only Manual Crop styles'),
'#description' => t('Enable this option to filter out all image styles without a Manual Crop effect.'),
'#default_value' => !empty($settings['manualcrop_filter_insert']),
'#weight' => -1,
'#states' => array(
'disabled' => array(
'input[name="instance[widget][settings][manualcrop_enable]"]' => array(
'checked' => FALSE,
),
),
),
);
// If checked, remove all non-Manual Crop styles.
if (!empty($settings['manualcrop_enable']) && !empty($settings['manualcrop_filter_insert'])) {
$styles = array_merge(array(
'image' => 0,
), manualcrop_insert_styles());
$insert['insert_styles']['#options'] = array_intersect_key($insert['insert_styles']['#options'], $styles);
$insert['insert_default']['#options'] = array_intersect_key($insert['insert_default']['#options'], $styles);
}
}
}