function file_load

Same name in other branches
  1. 7.x includes/file.inc \file_load()

Loads a single file entity from the database.

Parameters

int $fid: A file ID.

bool $reset: (optional) Whether to reset the internal file_load_multiple() cache. Defaults to FALSE.

Return value

\Drupal\file\FileInterface|null A file entity or NULL if the file was not found.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\file\Entity\File::load().

See also

https://www.drupal.org/node/2266845

1 call to file_load()
FileLegacyTest::testEntityLegacyCode in core/modules/file/tests/src/Kernel/FileLegacyTest.php
@expectedDeprecation file_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::loadMultiple(). See https://www.drupal.org/node/2266845 @expectedDeprecation file_load() is deprecated in…

File

core/modules/file/file.module, line 114

Code

function file_load($fid, $reset = FALSE) {
    @trigger_error('file_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\file\\Entity\\File::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED);
    if ($reset) {
        \Drupal::entityTypeManager()->getStorage('file')
            ->resetCache([
            $fid,
        ]);
    }
    return File::load($fid);
}

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