function hook_file_load

Load additional information into file entities.

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

Parameters

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

See also

file_load_multiple()

file_load()

2 functions implement hook_file_load()

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

entity_crud_hook_test_file_load in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_file_load().
file_test_file_load in drupal/core/modules/file/tests/file_test/file_test.module
Implements hook_file_load().

File

drupal/core/modules/file/file.api.php, line 36
Hooks for file module.

Code

function hook_file_load($files) {

  // Add the upload specific data into the file entity.
  $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;
    }
  }
}