function _manualcrop_process_file_entity_form in Manual Crop 7
Add the crop functionality to the File Entity form.
Parameters
$form: Complete form array.
$form_state: Form state array.
$instance_info: Field instance info, this array should contain 3 keys: entity_type, bundle and field_name.
2 calls to _manualcrop_process_file_entity_form()
- manualcrop_form_file_entity_add_upload_alter in ./
manualcrop.module - Implements hook_form_FORM_ID_alter().
- manualcrop_form_file_entity_edit_alter in ./
manualcrop.module - Implements hook_form_FORM_ID_alter().
File
- ./
manualcrop.helpers.inc, line 557 - Helper functions for the Manual Crop module.
Code
function _manualcrop_process_file_entity_form(&$form, &$form_state, $instance_info) {
// Check if a field instance was specified and get its settings.
if (!empty($instance_info['entity_type']) && !empty($instance_info['bundle']) && !empty($instance_info['field_name'])) {
$instance = field_info_instance($instance_info['entity_type'], $instance_info['field_name'], $instance_info['bundle']);
if (!empty($instance)) {
$settings = $instance['widget']['settings'];
}
}
// No valid fields instance specified, use the File Entity settings.
if (!isset($settings)) {
$settings = variable_get('manualcrop_file_entity_settings_' . $form['#entity']->type, manualcrop_default_widget_settings());
}
// Add the croptool if Manual Crop has been enabled.
if (!empty($settings['manualcrop_enable'])) {
manualcrop_croptool_process($form, $form_state, $form, $form['#entity'], $settings);
// Add the submit handler. Sometimes we have to add it to the action button
// and sometimes we have to add it to the general #submit, based on whether
// or not the submit button already has a handler.
if (!empty($form['actions']['submit']['#submit'])) {
$form['actions']['submit']['#submit'][] = 'manualcrop_croptool_submit';
}
else {
$form['#submit'][] = 'manualcrop_croptool_submit';
}
}
}