You are here

function epsacrop_crop_image_form in EPSA Crop - Image Cropping 7.2

Same name and namespace in other branches
  1. 8.2 epsacrop.module \epsacrop_crop_image_form()

Function that provide the effect form settings for dialog crop.

@access public

Parameters

mixed $data:

Return value

void

1 string reference to 'epsacrop_crop_image_form'
epsacrop_image_effect_info in ./epsacrop.module
Implements hook_image_effect_info.

File

./epsacrop.module, line 309
The main file of module

Code

function epsacrop_crop_image_form($data) {
  $data += array(
    'jcrop_settings' => array(
      'bgcolor' => 'black',
      'bgopacity' => '0.6',
    ),
  );

  //@TODO Propose a alternative style (whitout Crop Dialog effect) instead of this
  $form = image_crop_form($data);

  // Override default
  $form['width']['#required'] = FALSE;
  $form['height']['#required'] = FALSE;

  // Add validation callbacks to ensure that at least one value has been added
  $form['height']['#element_validate'] = array(
    '_epsacrop_height_validate',
  );
  $form['width']['#element_validate'] = array(
    '_epsacrop_width_validate',
  );

  // Change description for the anchor
  $form['anchor']['#description'] = t("The part of the image that will be retained during the crop if no coordinates are set.");
  $form['disable_scale'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable image scaling'),
    '#description' => t("Only crop the image to the selected area and don't scale it. When enabled the above dimensions are used only when the cropping area is not selected."),
    '#default_value' => isset($data['disable_scale']) ? $data['disable_scale'] : 0,
  );
  $form['jcrop_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t("Advanced settings"),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['jcrop_settings']['aspect_ratio'] = array(
    '#type' => 'textfield',
    '#title' => t('Aspect Ratio'),
    '#description' => t("Aspect ratio of w/h (e.g. 1 for square)"),
    '#default_value' => isset($data['jcrop_settings']['aspect_ratio']) ? $data['jcrop_settings']['aspect_ratio'] : '',
    // '#field_suffix' => ' ' . t('pixels'),
    // '#required' => TRUE,
    '#size' => 10,
    '#element_validate' => array(
      '_epsacrop_aspect_ratio_validate',
    ),
  );

  /*
  $form['jcrop_settings']['minsize'] = array();
  $form['jcrop_settings']['maxsize'] = array();
  */
  $form['jcrop_settings']['bgcolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Background color'),
    '#description' => t("Set color of background container"),
    '#default_value' => isset($data['jcrop_settings']['bgcolor']) ? $data['jcrop_settings']['bgcolor'] : '',
    // '#field_suffix' => ' ' . t('pixels'),
    '#required' => TRUE,
    '#size' => 10,
  );
  $form['jcrop_settings']['bgopacity'] = array(
    '#type' => 'textfield',
    '#title' => t('Background opacity'),
    '#description' => t("Opacity of outer image when cropping"),
    '#default_value' => isset($data['jcrop_settings']['bgopacity']) ? $data['jcrop_settings']['bgopacity'] : '',
    // '#field_suffix' => ' ' . t('pixels'),
    '#required' => TRUE,
    '#size' => 10,
  );
  $form['jcrop_settings']['fallback'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ignore if not manually set'),
    '#description' => t("If a user does not manually set the crop, ignore these settings.  This is useful if you want to use other effects to set a default crop, which may then be overridden manually using EPSA Crop.  When this is checked, make sure the EPSA Crop effect is above any default cropping effects."),
    '#default_value' => isset($data['jcrop_settings']['fallback']) ? $data['jcrop_settings']['fallback'] : FALSE,
  );
  return $form;
}