function file_field_load in Drupal 7
Implements hook_field_load().
1 call to file_field_load()
- image_field_load in modules/
image/ image.field.inc - 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);
}
}
}
}