function imagefield_crop_field_widget_settings_form in Imagefield Crop 7
Same name and namespace in other branches
- 7.3 imagefield_crop.module \imagefield_crop_field_widget_settings_form()
- 7.2 imagefield_crop.module \imagefield_crop_field_widget_settings_form()
Implements hook_field_widget_settings_form().
File
- ./
imagefield_crop.module, line 75 - Provide a widget to crop uploaded image.
Code
function imagefield_crop_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = $widget['settings'];
// Use the image widget settings form.
$form = image_field_widget_settings_form($field, $instance);
$form['collapsible'] = array(
'#type' => 'radios',
'#title' => t('Collapsible behavior'),
'#options' => array(
1 => t('None.'),
2 => t('Collapsible, expanded by default.'),
3 => t('Collapsible, collapsed by default.'),
),
'#default_value' => $settings['collapsible'],
);
// Resolution settings.
$resolution = explode('x', $settings['resolution']) + array(
'',
'',
);
$form['resolution'] = array(
'#title' => t('The resolution to crop the image onto'),
'#element_validate' => array(
'_image_field_resolution_validate',
'_imagefield_crop_widget_resolution_validate',
),
'#theme_wrappers' => array(
'form_element',
),
'#description' => t('The output resolution of the cropped image, expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 not to rescale after cropping. Note: output resolution must be defined in order to present a dynamic preview.'),
);
$form['resolution']['x'] = array(
'#type' => 'textfield',
'#default_value' => $resolution[0],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => ' x ',
'#theme_wrappers' => array(),
);
$form['resolution']['y'] = array(
'#type' => 'textfield',
'#default_value' => $resolution[1],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => ' ' . t('pixels'),
'#theme_wrappers' => array(),
);
$form['enforce_ratio'] = array(
'#type' => 'checkbox',
'#title' => t('Enforce crop box ratio'),
'#default_value' => $settings['enforce_ratio'],
'#description' => t('Check this to force the ratio of the output on the crop box. NOTE: If you leave this unchecked but enforce an output resolution, the final image might be distorted'),
'#element_validate' => array(
'_imagefield_crop_widget_enforce_ratio_validate',
),
);
$form['enforce_minimum'] = array(
'#type' => 'checkbox',
'#title' => t('Enforce minimum crop size based on the output size'),
'#default_value' => $settings['enforce_minimum'],
'#description' => t('Check this to force a minimum cropping selection equal to the output size. NOTE: If you leave this unchecked you might get zoomed pixels if the cropping area is smaller than the output resolution.'),
'#element_validate' => array(
'_imagefield_crop_widget_enforce_minimum_validate',
),
);
// Crop area settings.
$croparea = explode('x', $settings['croparea']) + array(
'',
'',
);
$form['croparea'] = array(
'#title' => t('The resolution of the cropping area'),
'#element_validate' => array(
'_imagefield_crop_widget_croparea_validate',
),
'#theme_wrappers' => array(
'form_element',
),
'#description' => t('The resolution of the area used for the cropping of the image. Image will displayed at this resolution for cropping. Use WIDTHxHEIGHT format, empty or zero values are permitted, e.g. 500x will limit crop box to 500 pixels width.'),
);
$form['croparea']['x'] = array(
'#type' => 'textfield',
'#default_value' => $croparea[0],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => ' x ',
'#theme_wrappers' => array(),
);
$form['croparea']['y'] = array(
'#type' => 'textfield',
'#default_value' => $croparea[1],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => ' ' . t('pixels'),
'#theme_wrappers' => array(),
);
return $form;
}