You are here

function manualcrop_crop_form in Manual Crop 7

Form builder; Configuration settings for crop effect.

Parameters

$data: The current configuration for this crop effect.

Return value

The form structure array.

1 string reference to 'manualcrop_crop_form'
manualcrop_image_effect_info in ./manualcrop.module
Implements hook_image_effect_info().

File

./manualcrop.admin.inc, line 120
Admin functionality for the Manual Crop module.

Code

function manualcrop_crop_form($data) {
  $form = image_resize_form($data);
  $form['width']['#title'] = t('Minimum crop width');
  $form['width']['#description'] = t('Only applied if a user tries to crop, this enforces no minimum image width!');
  $form['width']['#required'] = FALSE;
  $form['height']['#title'] = t('Minimum crop height');
  $form['height']['#description'] = t('Only applied if a user tries to crop, this enforces no minimum image height!');
  $form['height']['#required'] = FALSE;
  $form['keepproportions'] = array(
    '#type' => 'checkbox',
    '#title' => t('Maintain proportions'),
    '#description' => t('Maintain the proportions while cropping. This requires setting a width and height.'),
    '#default_value' => !empty($data['keepproportions']),
    '#element_validate' => array(
      'manualcrop_keepproportions_validate',
    ),
    '#states' => array(
      'enabled' => array(
        'input[name="data[width]"]' => array(
          'filled' => TRUE,
        ),
        'input[name="data[height]"]' => array(
          'filled' => TRUE,
        ),
      ),
    ),
  );

  // Load the crop image styles and exclude the style that's being edited.
  $styles = manualcrop_styles_with_crop(FALSE, 5, TRUE);
  $form['reuse_crop_style'] = array(
    '#type' => 'select',
    '#title' => t('Fallback cropping style'),
    '#description' => t('The image style whose cropping should be applied if none is given for this style.'),
    '#options' => array(
      '' => '- ' . t('None (no crop)') . ' -',
    ) + $styles,
    '#default_value' => isset($data['reuse_crop_style']) ? $data['reuse_crop_style'] : '',
  );
  return $form;
}