function hook_file_load
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
Related topics
4 functions implement hook_file_load()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- EntityCrudHookTestHooks::fileLoad in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ src/ Hook/ EntityCrudHookTestHooks.php - Implements hook_ENTITY_TYPE_load() for file entities.
- entity_crud_hook_test_file_load in modules/
simpletest/ tests/ entity_crud_hook_test.module - Implements hook_file_load().
- FileTestHooks::fileLoad in core/
modules/ file/ tests/ file_test/ src/ Hook/ FileTestHooks.php - Implements hook_ENTITY_TYPE_load() for file entities.
- file_test_file_load in modules/
simpletest/ tests/ file_test.module - Implements hook_file_load().
File
-
modules/
system/ system.api.php, line 2838
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;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.