On this page
function file_field_load
file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
Implements hook_field_load().
File
- modules/file/file.field.inc, line 170
- Field module functionality for the File module.
Code
function file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
$fids = array();
foreach ($entities as $id => $entity) {
// Load the files from the files table.
foreach ($items[$id] as $delta => $item) {
if (!empty($item['fid'])) {
$fids[] = $item['fid'];
}
}
}
$files = file_load_multiple($fids);
foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => $item) {
// If the file does not exist, mark the entire item as empty.
if (empty($item['fid']) || !isset($files[$item['fid']])) {
$items[$id][$delta] = NULL;
}
else {
$items[$id][$delta] = array_merge((array) $files[$item['fid']], $item);
}
}
}
}
© 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!file!file.field.inc/function/file_field_load/7.x