Browse Source

Provide some more info when handling avatars fails

Signed-off-by: Suki <[email protected]>
Suki 10 years ago
parent
commit
b349538bd4
2 changed files with 7 additions and 4 deletions
  1. 3 3
      Sources/Profile-Modify.php
  2. 4 1
      Themes/default/languages/Errors.english.php

+ 3 - 3
Sources/Profile-Modify.php

@@ -2941,7 +2941,7 @@ function profileSaveAvatarData(&$value)
 			$profile_vars['avatar'] = '';
 		// Trying to make us do something we'll regret?
 		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
-			return 'bad_avatar';
+			return 'bad_avatar_invalid_url';
 		// Should we check dimensions?
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
 		{
@@ -2952,7 +2952,7 @@ function profileSaveAvatarData(&$value)
 			{
 				// Houston, we have a problem. The avatar is too large!!
 				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
-					return 'bad_avatar';
+					return 'bad_avatar_too_large';
 				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
 				{
 					// @todo remove this if appropriate
@@ -3032,7 +3032,7 @@ function profileSaveAvatarData(&$value)
 					if (empty($modSettings['avatar_reencode']) || (!reencodeImage($_FILES['attachment']['tmp_name'], $sizes[2])))
 					{
 						@unlink($_FILES['attachment']['tmp_name']);
-						return 'bad_avatar';
+						return 'bad_avatar_fail_reencode';
 					}
 					// We were successful. However, at what price?
 					$sizes = @getimagesize($_FILES['attachment']['tmp_name']);

+ 4 - 1
Themes/default/languages/Errors.english.php

@@ -334,7 +334,10 @@ $txt['profile_error_email_taken'] = 'Another user is already registered with tha
 $txt['profile_error_no_password'] = 'You did not enter your password';
 $txt['profile_error_bad_new_password'] = 'The new passwords you entered do not match';
 $txt['profile_error_bad_password'] = 'The password you entered was not correct';
-$txt['profile_error_bad_avatar'] = 'The avatar you have selected is either too large or not an avatar';
+$txt['profile_error_bad_avatar'] = 'The avatar you have selected is not a valid image';
+$txt['profile_error_bad_avatar_invalid_url'] = 'The url you specified is invalid, please check it.';
+$txt['profile_error_bad_avatar_too_large'] = 'The image you\'re trying to use surpasses the max width/height settings, please use a smaller one.';
+$txt['profile_error_bad_avatar_fail_reencode'] = 'The image you uploaded was corrupted and the attempt to restored failed to do so.';
 $txt['profile_error_password_short'] = 'Your password must be at least ' . (empty($modSettings['password_strength']) ? 4 : 8) . ' characters long.';
 $txt['profile_error_password_restricted_words'] = 'Your password must not contain your username, email address or other commonly used words.';
 $txt['profile_error_password_chars'] = 'Your password must contain a mix of upper and lower case letters, as well as digits.';