You are here

function hook_scald_add_form_fill in Scald: Media Management made easy 7

Fills default atom data.

When a form is uploaded, one or more atoms are created, but it is not saved. This is a last chance for atom provider to add default data, maybe from the form, into atoms.

@codingStandardsIgnoreStart

Parameters

mixed $atoms: An array of atoms if the provider implements hook_scald_add_atom_count(), otherwise a single atom.

array $form: The form array.

array $form_state: The form state array.

Related topics

4 functions implement hook_scald_add_form_fill()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

scald_audio_scald_add_form_fill in modules/providers/scald_audio/scald_audio.module
Implements hook_scald_add_form_fill().
scald_flash_scald_add_form_fill in modules/providers/scald_flash/scald_flash.module
Implements hook_scald_add_form_fill.
scald_image_scald_add_form_fill in modules/providers/scald_image/scald_image.module
Implements hook_scald_add_form_fill().
scald_video_scald_add_form_fill in modules/providers/scald_video/scald_video.module
Implements hook_scald_add_form_fill().

File

./scald.api.php, line 575
Hooks related to Scald atoms and providers.

Code

function hook_scald_add_form_fill(&$atoms, $form, $form_state) {

  // @codingStandardsIgnoreEnd
  foreach ($atoms as $delta => $atom) {
    if (is_array($form_state['values']['file']) && module_exists('plupload')) {
      module_load_include('inc', 'scald', 'includes/scald.plupload');
      $file = scald_plupload_save_file($form_state['values']['file'][$delta]['tmppath'], $form['file']['#upload_location'] . $form_state['values']['file'][$delta]['name']);
    }
    else {
      $file = file_load($form_state['values']['file']);
    }
    $atom->title = $file->filename;
    $atom->base_id = $file->fid;
    $langcode = field_language('scald_atom', $atom, 'scald_thumbnail');
    $atom->scald_thumbnail[$langcode][0] = (array) $file;
  }
}