Index: user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user.module,v retrieving revision 1.516 diff -u -p -r1.516 user.module --- user.module 9 Oct 2005 10:39:15 -0000 1.516 +++ user.module 10 Oct 2005 18:59:33 -0000 @@ -241,23 +241,16 @@ function user_validate_picture($file, &$ // Initialize the picture: $edit['picture'] = $user->picture; - // Check that uploaded file is an image, with a maximum file size - // and maximum height/width. + // Check that uploaded file is an image and determine the + // dimensions to resize it to $info = image_get_info($file->filepath); list($maxwidth, $maxheight) = explode('x', variable_get('user_picture_dimensions', '85x85')); if (!$info || !$info['extension']) { - form_set_error('picture', t('The uploaded file was not an image.')); - } - else if (image_get_toolkit()) { + form_set_error('picture', t('The uploaded file must be an image and have one of the following file extensions: .jpg, .gif, .png.')); + } else { image_scale($file->filepath, $file->filepath, $maxwidth, $maxheight); } - else if (filesize($file->filepath) > (variable_get('user_picture_file_size', '30') * 1000)) { - form_set_error('picture', t('The uploaded image is too large; the maximum file size is %size kB.', array('%size' => variable_get('user_picture_file_size', '30')))); - } - else if ($info['width'] > $maxwidth || $info['height'] > $maxheight) { - form_set_error('picture', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85')))); - } if (!form_get_errors()) { if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) { @@ -1168,13 +1161,13 @@ function user_edit_form($uid, $edit) { } // Picture/avatar: - if (variable_get('user_pictures', 0)) { + if (variable_get('user_pictures', 0) && image_get_toolkit()) { $form['picture'] = array(type => 'fieldset', title => t('Picture'), weight => 1); if ($edit['picture'] && ($picture = theme('user_picture', array2object($edit)))) { $form['picture']['current_picture'] = array(type => 'markup', value => $picture); $form['picture']['picture_delete'] = array(type => 'checkbox', title => t('Delete picture'), return_value => 1, default_value => 0, description => t('Check this box to delete your current picture.')); } - $form['picture']['picture'] = array(type => 'file', title => t('Upload picture'), size => 48, description => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', '')); + $form['picture']['picture'] = array(type => 'file', title => t('Upload picture'), size => 48, description => t('Your virtual face or picture. Images must be less than than '. ini_get(upload_max_filesize) . 'B.')); } return $form;