function image_effect_form

8.x 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 callback' specified in hook_image_effect_info().

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

image_resize_form()

image_scale_form()

image_rotate_form()

image_crop_form()

image_effect_form_submit()

Related topics

1 string reference to 'image_effect_form'
image_menu in drupal/core/modules/image/image.module
Implements hook_menu().

File

drupal/core/modules/image/image.admin.inc, line 283
Administration pages for image settings.

Code

function image_effect_form($form, &$form_state, $style, $effect) {
  // If there's no configuration for this image effect, return to
  // the image style page.
  if (!isset($effect['form callback'])) {
    drupal_goto('admin/config/media/image-styles/manage/' . $style->id());
  }
  $form_state['image_style'] = $style;
  $form_state['image_effect'] = $effect;

  if (!empty($effect['ieid'])) {
    $title = t('Edit %label effect', array('%label' => $effect['label']));
  }
  else {
    $title = t('Add %label effect', array('%label' => $effect['label']));
  }
  drupal_set_title($title, PASS_THROUGH);

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

  $form['ieid'] = array(
    '#type' => 'value',
    '#value' => !empty($effect['ieid']) ? $effect['ieid'] : NULL,
  );
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $effect['name'],
  );

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

  // 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('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => !empty($effect['ieid']) ? t('Update effect') : t('Add effect'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => 'admin/config/media/image-styles/manage/' . $style->id(),
  );

  return $form;
}