function file_field_load

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

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']])) {
                unset($items[$id][$delta]);
            }
            else {
                $items[$id][$delta] = array_merge((array) $files[$item['fid']], $item);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.