You are here

function media_watermark_prepare_batch in Media watermark 7

Batch operation: prepare batch to add watermarks to images.

Parameters

array $form_state: form state array

Return value

array batch operations array

1 call to media_watermark_prepare_batch()
media_watermark_add_upload_multiple_submit in ./media_watermark.module
Function which make same things as file_entity__add_upload_multiple_submit().

File

./media_watermark.module, line 306
Watermark media module.

Code

function media_watermark_prepare_batch($form_state) {
  drupal_set_message(t('Adding watermarks.'));
  foreach ($form_state['files'] as $value) {
    $file_path = drupal_realpath($value->uri);
    $operations[] = array(
      'media_watermark_process_multiple_images',
      array(
        $file_path,
        $form_state,
      ),
    );
  }
  $batch = array(
    'operations' => $operations,
    'finished' => 'media_watermark_batch_finished',
    'init_message' => 'Prepare data.',
    'progress_message' => 'Executed @current from @total.',
    'error_message' => 'An error has occurred.',
  );
  return $batch;
}