function hook_file_load

hook_file_load($files)

Load additional information into file objects.

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

Parameters

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

See also

file_load_multiple()

file_load()

Related topics

File

modules/system/system.api.php, line 2822
Hooks provided by Drupal core and the System module.

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;
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_file_load/7.x