You are here

function filefield_meta_file_load in FileField 6.3

Implementation of FileField's hook_file_load().

File

filefield_meta/filefield_meta.module, line 58
FileField Meta: Add Video Support to File Field.

Code

function filefield_meta_file_load(&$file) {
  $result = db_query("SELECT * FROM {filefield_meta} WHERE fid = %d", $file->fid);
  $data = db_fetch_array($result);

  // Essentially this is a lazy-loader. If no record exists, read in the file.
  if ($data) {
    $data['tags'] = isset($data['tags']) ? unserialize($data['tags']) : array();
    $file->data = isset($file->data) ? array_merge($file->data, $data) : $data;
  }
  else {
    filefield_meta_file_insert($file);
  }
}