hook_file_load

Definition

hook_file_load($files)
drupal/modules/system/system.api.php, line 996

Description

Load additional information into file objects.

file_load_multiple() calls this hook to allow modules to load additional information into each file.

@see file_load_multiple() @see upload_file_load()

Parameters

$files An array of file objects, indexed by fid.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

function hook_file_load($files) {
  // Add the upload specific data into the file object.
  $result = db_query('SELECT * FROM {upload} u WHERE u.fid IN (:fids)', array(':fids' => array_keys($files)))->fetchAll(PDO::FETCH_ASSOC);
  foreach ($result as $record) {
    foreach ($record as $key => $value) {
      $files[$record['fid']]->$key = $value;
    }
  }
}