You are here

function file_entity_file_load in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.file.inc \file_entity_file_load()

Implements hook_file_load().

File

./file_entity.file.inc, line 185
File hooks implemented by the File entity module.

Code

function file_entity_file_load($files) {

  // Add alt and title text to images.
  file_entity_set_title_alt_properties($files);

  // Add metadata to each file.
  foreach ($files as $file) {
    $file->metadata = array();
  }
  $results = db_query("SELECT * FROM {file_metadata} WHERE fid IN (:fids)", array(
    ':fids' => array_keys($files),
  ));
  foreach ($results as $result) {
    $name = $result->name;

    // image.module required height and width to be properties of the file.
    if ($name == 'height' || $name == 'width') {
      $files[$result->fid]->{$name} = unserialize($result->value);
    }
    $files[$result->fid]->metadata[$name] = unserialize($result->value);
  }
}