function path_file_insert in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.module \path_file_insert()
Implements hook_file_insert() on behalf of path.module.
File
- ./
file_entity.module, line 2516 - Extends Drupal file entities to be fieldable and viewable.
Code
function path_file_insert($file) {
if (isset($file->path)) {
$path = $file->path;
$path['alias'] = trim($path['alias']);
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'file/' . $file->fid;
// Core does not provide a way to store the file language but contrib
// modules can do it so we need to take this into account.
$langcode = entity_language('file', $file);
$path['language'] = !empty($langcode) ? $langcode : LANGUAGE_NONE;
path_save($path);
}
}
}