You are here

function file_resup_value in File Resumable Upload 8

Same name and namespace in other branches
  1. 7 file_resup.field.inc \file_resup_value()

#value_callback callback for the resup element.

1 string reference to 'file_resup_value'
file_resup_field_widget_process in ./file_resup.field.inc
#process callback for the field widget element.

File

./file_resup.field.inc, line 184
Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Code

function file_resup_value($element, $input = FALSE, $form_state = array()) {
  $fids = array();
  if ($input) {
    $resup_file_ids = explode(',', $input);
    array_shift($resup_file_ids);
    if (isset($element['#attributes']['data-max-files'])) {
      $resup_file_ids = array_slice($resup_file_ids, 0, max(0, $element['#attributes']['data-max-files'] - 1));
    }
    foreach ($resup_file_ids as $resup_file_id) {
      if ($file = file_resup_save_upload($element, $resup_file_id)) {
        $fids[] = $file->fid;
      }
    }
  }
  return implode(',', $fids);
}