function uploadfield_widget_upload_validators in Video 6.3
Get the additional upload validators for an image field.
Parameters
$field: The CCK field array.
Return value
An array suitable for passing to file_save_upload() or the file field element's '#upload_validators' property.
File
- types/
uploadfield/ uploadfield.module, line 254
Code
function uploadfield_widget_upload_validators($field) {
$validators = array();
// Ensure that only web images are supported.
$web_extensions = array(
'mov',
'mp4',
'3gp',
'3g2',
'mpg',
'mpeg',
// quicktime
'divx',
//divx
'rm',
// realplayer
'flv',
'f4v',
//flash player
'swf',
// swf player
'dir',
'dcr',
// dcr player
'asf',
'wmv',
'avi',
'mpg',
'mpeg',
// windows media
'ogg',
);
$extensions = array_filter(explode(' ', $field['widget']['file_extensions']));
if (empty($extensions)) {
$extensions = $web_extensions;
}
$validators['filefield_validate_extensions'][0] = implode(' ', array_intersect($extensions, $web_extensions));
// Add the image validator as a basic safety check.
// $validators['filefield_validate_is_image'] = array();
// Add validators for resolutions.
// if (!empty($field['widget']['max_resolution']) || !empty($field['widget']['min_resolution'])) {
// $validators['filefield_validate_image_resolution'] = array(
// $field['widget']['max_resolution'],
// $field['widget']['min_resolution'],
// );
// }
return $validators;
}