file_field_presave
function file_field_presave
file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Implements hook_field_presave().
File
- modules/file/file.field.inc, line 215
- Field module functionality for the File module.
Code
function file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { // Make sure that each file which will be saved with this object has a // permanent status, so that it will not be removed when temporary files are // cleaned up. foreach ($items as $delta => $item) { if (empty($item['fid'])) { unset($items[$delta]); continue; } $file = file_load($item['fid']); if (empty($file)) { unset($items[$delta]); continue; } if (!$file->status) { $file->status = FILE_STATUS_PERMANENT; file_save($file); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!file!file.field.inc/function/file_field_presave/7.x