1 image.admin.inc image_effect_form($form, &$form_state, $style, $effect)

Form builder; Form for adding and editing image effects.

This form is used universally for editing all image effects. Each effect adds its own custom section to the form by calling the form function specified in hook_image_effects().

Parameters

$form_state: An associative array containing the current state of the form.

$style: An image style array.

$effect: An image effect array.

See also

hook_image_effects()

image_resize_form()

image_scale_form()

image_rotate_form()

image_crop_form()

image_effect_form_submit()

Related topics

File

core/modules/image/image.admin.inc, line 351
Admin page callbacks for the Image module.

Code

function image_effect_form($form, &$form_state, $style, $effect) {
  if (!empty($effect['data'])) {
    $title = t('Edit %label effect', array('%label' => $effect['label']));
  }
  else {
    $title = t('Add %label effect', array('%label' => $effect['label']));
  }
  backdrop_set_title($title, PASS_THROUGH);

  $form_state['image_style'] = $style;
  $form_state['image_effect'] = $effect;

  // If no configuration for this image effect, return to the image style page.
  if (!isset($effect['form callback'])) {
    backdrop_goto('admin/config/media/image-styles/configure/' . $style['name']);
  }

  $form['#tree'] = TRUE;
  $form['#attached']['css'][backdrop_get_path('module', 'image') . '/css/image.admin.css'] = array();

  $form['data'] = call_user_func($effect['form callback'], $effect['data']);

  // Check the URL for a weight, then the image effect, otherwise use default.
  $form['weight'] = array(
    '#type' => 'hidden',
    '#value' => isset($_GET['weight']) ? intval($_GET['weight']) : (isset($effect['weight']) ? $effect['weight'] : count($style['effects'])),
  );

  $form['actions'] = array('#tree' => FALSE, '#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => isset($effect['ieid']) ? t('Update effect') : t('Add effect'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => 'admin/config/media/image-styles/configure/' . $style['name'],
  );

  return $form;
}