function media_attach_file in D7 Media 7.3
Same name and namespace in other branches
- 7.4 media.module \media_attach_file()
- 7.2 media.module \media_attach_file()
Attaches any files that have been referenced by a media element.
Parameters
$element: The FAPI element whose files are being attached.
Return value
The file object representing the file that was attached, or FALSE if no file was attached.
1 call to media_attach_file()
- media_file_value in ./
media.module - The #value_callback for a media type element.
File
- ./
media.module, line 1029 - Media API
Code
function media_attach_file($element) {
$upload_name = implode('_', $element['#parents']);
if (empty($_POST['media'][$upload_name])) {
return FALSE;
}
if (!($file = file_load($_POST['media'][$upload_name]))) {
watchdog('file', 'The file upload failed. %upload', array(
'%upload' => $upload_name,
));
form_set_error($upload_name, t('The file in the !name field was unable to be uploaded.', array(
'!name' => $element['#title'],
)));
return FALSE;
}
return $file;
}