1 file.field.inc | file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) |
Implements hook_field_load().
File
- core/
modules/ file/ file.field.inc, line 187 - 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);
}
}
}
}