function image_effect_form

7.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 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_effects()

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/modules/image/image.module
Implements hook_menu().

File

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

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']));
  }
  drupal_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'])) {
    drupal_goto('admin/config/media/image-styles/edit/' . $style['name']);
  }

  $form['#tree'] = TRUE;
  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
  if (function_exists($effect['form callback'])) {
    $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/edit/' . $style['name'],
  );

  return $form;
}