function manualcrop_insert_element_process in Manual Crop 7
Additional after build callback to modify form elements added by the Insert module.
1 string reference to 'manualcrop_insert_element_process'
- manualcrop_field_widget_form_alter in ./
manualcrop.module - Implements hook_field_widget_form_alter().
File
- ./
manualcrop.module, line 329
Code
function manualcrop_insert_element_process($element) {
foreach (element_children($element) as $key) {
if (!empty($element[$key]['insert']['#options']) && !empty($element[$key]['manualcrop_selections'])) {
$settings = $element[$key]['insert']['#widget']['settings'];
// Increase the select list weight.
$element[$key]['insert']['#weight'] = 0;
if (!empty($settings['manualcrop_filter_insert'])) {
// Make a list of all styles that should be visible in the widget.
$styles = array(
'image' => 1,
);
foreach (element_children($element[$key]['manualcrop_selections']) as $style) {
$styles['image_' . $style] = 1;
}
// Filter hidden styles from Insert.
$element[$key]['insert']['#options'] = array_intersect_key($element[$key]['insert']['#options'], $styles);
// Make sure the default value is allowed.
if (!array_key_exists($element[$key]['insert']['#default_value'], $element[$key]['insert']['#options'])) {
reset($element[$key]['insert']['#options']);
$element[$key]['insert']['#default_value'] = key($element[$key]['insert']['#options']);
}
}
}
}
return $element;
}