You are here

function imageapi_optimize_pipeline_form_submit in Image Optimize (or ImageAPI Optimize) 7.2

Submit handler for saving an image pipeline.

1 string reference to 'imageapi_optimize_pipeline_form_submit'
imageapi_optimize_pipeline_form in ./imageapi_optimize.admin.inc
Form builder; Edit an image pipeline name and effects order.

File

./imageapi_optimize.admin.inc, line 223

Code

function imageapi_optimize_pipeline_form_submit($form, &$form_state) {

  // Update the image pipeline.
  $pipeline = $form_state['pipeline'];
  $pipeline['name'] = $form_state['values']['name'];
  $pipeline['label'] = $form_state['values']['label'];

  // Update image effect weights.
  if (!empty($form_state['values']['processors'])) {
    foreach ($form_state['values']['processors'] as $ieid => $processor_data) {
      if (isset($pipeline['processors'][$ieid])) {
        $processor = $pipeline['processors'][$ieid];
        $processor['weight'] = $processor_data['weight'];
        imageapi_optimize_processor_save($processor);
      }
    }
  }
  imageapi_optimize_pipeline_save($pipeline);
  if ($form_state['values']['op'] == t('Update pipeline')) {
    drupal_set_message(t('Changes to the pipeline have been saved.'));
  }
  $form_state['redirect'] = 'admin/config/media/imageapi-optimize/edit/' . $pipeline['name'];
}