diff --git a/Sources/Profile.php b/Sources/Profile.php
index 53bf4dcf32..ec3208340c 100644
--- a/Sources/Profile.php
+++ b/Sources/Profile.php
@@ -1218,7 +1218,6 @@ public function loadAvatarData(): bool
// Get a list of all the server stored avatars.
if ($this->avatar->allow_server_stored) {
- Utils::$context['avatar_list'] = [];
Utils::$context['avatars'] = is_dir(Config::$modSettings['avatar_directory']) ? $this->getAvatars('', 0) : [];
} else {
Utils::$context['avatars'] = [];
@@ -2607,14 +2606,12 @@ protected function getAvatars(string $directory, int $level = 0): array
$result[] = [
'filename' => Utils::htmlspecialchars($line),
- 'checked' => $line == Utils::$context['member']['avatar']['server_pic'],
+ // server_pic names the directory too, so a file one level down
+ // has to be compared against the path, not just its own name.
+ 'checked' => ($directory === '' ? $line : $directory . '/' . $line) == Utils::$context['member']['avatar']['server_pic'],
'name' => Utils::htmlspecialchars(str_replace('_', ' ', $filename)),
'is_dir' => false,
];
-
- if ($level == 1) {
- Utils::$context['avatar_list'][] = $directory . '/' . $line;
- }
}
return $result;
diff --git a/Themes/default/Profile.template.php b/Themes/default/Profile.template.php
index ef257af485..d7e97bfe57 100644
--- a/Themes/default/Profile.template.php
+++ b/Themes/default/Profile.template.php
@@ -2978,7 +2978,7 @@ function template_profile_avatar_select()
if (empty(Config::$modSettings['gravatarEnabled']) || empty(Config::$modSettings['gravatarOverride'])) {
echo '
-
+
';
@@ -2986,7 +2986,7 @@ function template_profile_avatar_select()
if (!empty(Utils::$context['member']['avatar']['allow_server_stored'])) {
echo '
-
+
';
@@ -2994,7 +2994,7 @@ function template_profile_avatar_select()
if (!empty(Utils::$context['member']['avatar']['allow_external'])) {
echo '
-
+
';
@@ -3002,7 +3002,7 @@ function template_profile_avatar_select()
if (!empty(Utils::$context['member']['avatar']['allow_upload'])) {
echo '
-
+
';
@@ -3010,7 +3010,7 @@ function template_profile_avatar_select()
if (!empty(Utils::$context['member']['avatar']['allow_gravatar'])) {
echo '
-
+
';
}
@@ -3022,59 +3022,55 @@ function template_profile_avatar_select()
// If users are allowed to choose avatars stored on the server show selection boxes to choice them from.
if (!empty(Utils::$context['member']['avatar']['allow_server_stored'])) {
echo '
-
+
-
-
-
-
-
';
}
// If the user can link to an off server avatar, show them a box to input the address.
if (!empty(Utils::$context['member']['avatar']['allow_external'])) {
echo '
-
';
}
// If the user is able to upload avatars to the server show them an upload box.
if (!empty(Utils::$context['member']['avatar']['allow_upload'])) {
echo '
-
';
}
@@ -3082,7 +3078,7 @@ function template_profile_avatar_select()
// if the user is able to use Gravatar avatars show then the image preview
if (!empty(Utils::$context['member']['avatar']['allow_gravatar'])) {
echo '
-