You are here

function imageapi_optimize_processor_form in Image Optimize (or ImageAPI Optimize) 7.2

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.

$pipeline: An image pipeline array.

$processor: 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()

1 string reference to 'imageapi_optimize_processor_form'
imageapi_optimize_menu in ./imageapi_optimize.module
Implements hook_menu().

File

./imageapi_optimize.admin.inc, line 402

Code

function imageapi_optimize_processor_form($form, &$form_state, $pipeline, $processor) {
  if (!empty($processor['data'])) {
    $title = t('Edit %label processor', array(
      '%label' => $processor['label'],
    ));
  }
  else {
    $title = t('Add %label processor', array(
      '%label' => $processor['label'],
    ));
  }
  drupal_set_title($title, PASS_THROUGH);
  $form_state['pipeline'] = $pipeline;
  $form_state['processor'] = $processor;
  $processor_handler = imageapi_optimize_processor_handler($processor);

  // If no configuration for this image effect, return to the image pipeline page.
  if (!is_a($processor_handler, 'ImageAPIOptimizeProcessorConfigurableInterface')) {
    drupal_goto('admin/config/media/imageapi-optimize/edit/' . $pipeline['name']);
  }
  $form['#tree'] = TRUE;
  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
  $form['data'] = $processor_handler
    ->configForm();

  // 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($processor['weight']) ? $processor['weight'] : count($pipeline['effects'])),
  );
  $form['actions'] = array(
    '#tree' => FALSE,
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => isset($processor['ieid']) ? t('Update processor') : t('Add processor'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => 'admin/config/media/imageapi-optimize/edit/' . $pipeline['name'],
  );
  return $form;
}