function media_update_file_presave in Media Update 7.2
Same name and namespace in other branches
- 7 media_update.module \media_update_file_presave()
Implements hook_file_presave().
Switches our media file's fid value so that all relevant hooks in file_save are executed with the original (rather than the new) file fid.
File
- ./
media_update.module, line 118 - Defines the module media_update.
Code
function media_update_file_presave($file) {
$original_file = _media_update_original_file();
// By checking if our original file exists, we ensure that we only swap the
// fid when we're doing a file update.
if (!empty($original_file) && (!isset($file->fid) || $original_file->fid != $file->fid)) {
// Let's try just swapping the file fid and see what happens. :-)
$file->fid = $original_file->fid;
}
}