summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2005-02-22 06:18:23 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2005-02-22 06:18:23 +0000
commitd2bfc1888075dac6e1a8946d3cf0d30ac9b79e5a (patch)
treec3f32d54d1bb3b6c6cd596383cb00068cbd6f70f /modules
parent9f5a97d6b72731abfb0a4086feb37a525e1f366b (diff)
downloadbrdo-d2bfc1888075dac6e1a8946d3cf0d30ac9b79e5a.tar.gz
brdo-d2bfc1888075dac6e1a8946d3cf0d30ac9b79e5a.tar.bz2
#17477: Remove dependency on GD for avatars.
Diffstat (limited to 'modules')
-rw-r--r--modules/user.module18
-rw-r--r--modules/user/user.module18
2 files changed, 24 insertions, 12 deletions
diff --git a/modules/user.module b/modules/user.module
index b95d62f05..74e4350f8 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -233,17 +233,23 @@ function user_validate_picture($file, &$edit, $user) {
if (!$info || !$info['extension']) {
form_set_error('picture', t('The uploaded file was not an image.'));
}
- else if (!image_scale($file->filepath, $file->filepath, $maxwidth, $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'))));
+ else if (image_get_toolkit()) {
+ 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 ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
- $edit['picture'] = $file->filepath;
+ 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'))));
}
- else {
- form_set_error('picture', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
+
+ if (!form_get_errors()) {
+ if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
+ $edit['picture'] = $file->filepath;
+ }
+ else {
+ form_set_error('picture', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
+ }
}
}
diff --git a/modules/user/user.module b/modules/user/user.module
index b95d62f05..74e4350f8 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -233,17 +233,23 @@ function user_validate_picture($file, &$edit, $user) {
if (!$info || !$info['extension']) {
form_set_error('picture', t('The uploaded file was not an image.'));
}
- else if (!image_scale($file->filepath, $file->filepath, $maxwidth, $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'))));
+ else if (image_get_toolkit()) {
+ 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 ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
- $edit['picture'] = $file->filepath;
+ 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'))));
}
- else {
- form_set_error('picture', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
+
+ if (!form_get_errors()) {
+ if ($file = file_save_upload('picture', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '.' . $info['extension'], 1)) {
+ $edit['picture'] = $file->filepath;
+ }
+ else {
+ form_set_error('picture', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => '<em>'. variable_get('user_picture_path', 'pictures') .'</em>')));
+ }
}
}