Fix the handling of a missing custom avatar
authorAlexander Ebert <ebert@woltlab.com>
Sat, 26 Aug 2023 18:15:11 +0000 (20:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 26 Aug 2023 18:15:11 +0000 (20:15 +0200)
See https://www.woltlab.com/community/thread/301317-error-trying-to-upload-an-avatar-by-acp/

wcfsetup/install/files/acp/templates/userAdd.tpl
wcfsetup/install/files/lib/acp/form/UserEditForm.class.php

index f05c8019b63fdffa8f3b978f9683a5056775885a..003891db3249f9e382fae175a09382b7dbc7638c 100644 (file)
 
                                        <dl class="avatarType jsOnly{if $errorType[customAvatar]|isset} formError{/if}" id="avatarUpload">
                                                <dt>
-                                                       {if $avatarType == 'custom'}
+                                                       {if $avatarType == 'custom' && $userAvatar !== null}
                                                                {@$userAvatar->getImageTag(96)}
                                                        {else}
                                                                <img src="{@$__wcf->getPath()}images/avatars/avatar-default.svg" alt="" class="userAvatarImage icon96">
index 0efc1c96d9eb21cde9bb7c514d67a6e0d72fa746..c4aeeae832db03fc9d396576b211e67e7fb1fcaf 100755 (executable)
@@ -282,7 +282,7 @@ class UserEditForm extends UserAddForm
         parent::readData();
 
         // get the avatar object
-        if ($this->avatarType == 'custom') {
+        if ($this->avatarType == 'custom' && $this->user->avatarID) {
             $this->userAvatar = new UserAvatar($this->user->avatarID);
         }