function file_entity_file_presave in File Entity (fieldable files) 7
Same name and namespace in other branches
- 7.3 file_entity.file.inc \file_entity_file_presave()
- 7.2 file_entity.file.inc \file_entity_file_presave()
Implements hook_file_presave().
File
- ./
file_entity.module, line 270 - Extends Drupal file entities to be fieldable and viewable.
Code
function file_entity_file_presave($file) {
// Always ensure the filemime property is current.
if (!empty($file->original) || empty($file->filemime)) {
$file->filemime = file_get_mimetype($file->uri);
}
// Always update file type based on filemime.
$file->type = file_get_type($file);
field_attach_presave('file', $file);
}