function user_validate_picture in Drupal 7
Same name and namespace in other branches
- 4 modules/user.module \user_validate_picture()
- 5 modules/user/user.module \user_validate_picture()
- 6 modules/user/user.module \user_validate_picture()
Validates an image uploaded by a user.
See also
1 string reference to 'user_validate_picture'
- user_account_form in modules/
user/ user.module - Helper function to add default user account fields to user registration and edit form.
File
- modules/
user/ user.module, line 687 - Enables the user registration and login system.
Code
function user_validate_picture(&$form, &$form_state) {
// If required, validate the uploaded picture.
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(
variable_get('user_picture_dimensions', '85x85'),
),
'file_validate_size' => array(
(int) variable_get('user_picture_file_size', '30') * 1024,
),
);
// Save the file as a temporary file.
$file = file_save_upload('picture_upload', $validators);
if ($file === FALSE) {
form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array(
'%directory' => variable_get('user_picture_path', 'pictures'),
)));
}
elseif ($file !== NULL) {
$form_state['values']['picture_upload'] = $file;
}
}