# How to fix user avatar?

**URL:** https://meta.discourse.org/t/how-to-fix-user-avatar/94675
**Category:** Support
**Created:** [August 14, 2018, 8:24am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675 "2018-08-14T08:24:00Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 14, 2018, 8:24am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/1 "2018-08-14T08:24:00Z")

</div>

Hi, one forum member asked me what happened with her avatar based on gravatar. It became default:

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/7/7/7720957eddbe5e99ac5b3bb775b07a062cb24284.png)  
First we tried to apply new gravatar picture and clean browser cache - nothing changes, then upload custom picture - it is shown in preview only. Logs are clean. Now we can switch between default grey icon and ‘S’ system icon.

I found the following topic where is described how to reset all avatars, maybe there is a command how to reset avatar for certain user? But I am not sure that it is a solution, anyway… I cannot restart/rebuild forum right now. The problem persists only for one person.

Appreciated for any help, thanks  
Ivan

> [@Reset all avatars back to default](https://meta.discourse.org/t/reset-all-avatars-back-to-default/64929/3):
>
> To reset all user avatars to system generated avatar, here is what needs to be done on server: cd /var/discourse ./launcher enter app rails c User.human\_users.update\_all(uploaded\_avatar\_id: nil)@Brock_Busby Since you are hosted by us, I can do this for you. Should I go ahead and reset all avatars on your Discourse instance?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [August 14, 2018, 9:55am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/2 "2018-08-14T09:55:00Z")

</div>

> [@Ivan\_Rapekas](#):
>
> how to reset avatar for certain user

```
rails c
User.find_by_username("username").update(uploaded_avatar_id: nil)

```

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 14, 2018, 10:44am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/4 "2018-08-14T10:44:15Z")

</div>

Thank you, @gerhard!

The command works fine, but this did not resolve the issue. Trying to find another solution…

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 14, 2018, 11:34am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/5 "2018-08-14T11:34:58Z")

</div>

Does it only affect that particular user or are other users affected as well? Can you get the user to try a different image to see if it works?

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 14, 2018, 11:40am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/6 "2018-08-14T11:40:35Z")

</div>

Hi Alan,  
Only one user affected. I checked the database and see, that table `uploads` missed one ID, the user `540` probably uploaded more than three avatars:

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/e/d/ed534ab7e0ed4f647faddb701b663acdbcf5eccd.png)

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 14, 2018, 11:45am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/7 "2018-08-14T11:45:59Z")

</div>

> [@tgxworld](#):
>
> Can you get the user to try a different image to see if it works?

No way to change picture. It always returns to default (grey without letter).

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 14, 2018, 1:14pm UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/8 "2018-08-14T13:14:18Z")

</div>

Just for info, I tried to play with backup and rebuild does not fix the problem. I can see preview the image after upload, but it disappears after save changes. Both forum admin (I am) and the user tried the same in two browsers on two different OS.

As for me, I have gravatar picture as well with the same settings (SSO forum email is secondary in gravatar service). All links in the database seem to be ok and they point to just uploaded picture, but in fact, it does not show…

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/f/3/f39d7b52efa54d87fbd0dbefecc5af5265932e1e.png)

What can I try else? v2.0.3 is used, not tests-passed.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 14, 2018, 11:03pm UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/9 "2018-08-14T23:03:56Z")

</div>

Have a look at the `UserAvatar` for the user and delete the uploads there. A simple way to create orphans would be:

```plaintext
a = UserAvatar.where(user_id: SOMEID).update_all(gravatar_upload_id: nil)

```

But the odd thing here is that “refresh” is meant to do something similar so maybe optimised images for the upload are junk.

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 15, 2018, 7:02am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/10 "2018-08-15T07:02:37Z")

</div>

Thank you for the reply, Sam!

Unfortunately nothing changes. The history was:  
2018-08-08: Forum upgraded from v1.9.4 to v2.0.3 (using tag)  
2018-08-09: User tried to change her avatar, uploading new file AV2.jpg. We don’t know the message was on user’s screen, probably about dimensions or filesize but the log returns `418` response. Comparing to database, I cannot find such file there, the line with obvious id=3465 is missed as well.

```plaintext
Started POST "/discuss/uploads.json?client_id= ***&authenticity_token=***" for 46.0.*.* at 2018-08-09 18:43:21 +0000
Processing by UploadsController#create as JSON
  Parameters: {"type"=>"avatar", "user_id"=>"540", "files"=>[#<ActionDispatch::Http::UploadedFile:0x00007f81c0c28550 @tempfile=#<Tempfile:/tmp/RackMultipart20180809-786-jqsr7k.jpg>, @original_filename="AV2.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"files[]\"; filename=\"AV2.jpg\"\r\nContent-Type: image/jpeg\r\n">], "client_id"=>" ***", "authenticity_token"=>"***"}
  Rendering text template
  Rendered text template (0.0ms)
Completed 418 in 13ms (Views: 0.5ms | ActiveRecord: 2.8ms)

```

So after that the user cannot change her avatar 🙂 . The file in /tmp folder already has deleted.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 15, 2018, 7:32am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/11 "2018-08-15T07:32:37Z")

</div>

Can you confirm you can not go to the user profile and simply upload a random image as an avatar for the user?

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 15, 2018, 7:57am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/12 "2018-08-15T07:57:31Z")

</div>

I can go to the user profile. I can change an avatar to  
 ![image](https://global.discourse-cdn.com/meta/original/3X/1/b/1b7b8a14974ae5bec420c62bb04a792649ac6538.png) only. I can choose another options, gravatar and custom picture (custom picture even is shown in preview), but they always change to ![generic](https://global.discourse-cdn.com/meta/original/4X/4/6/e/46e64dcab1d2b6828543f715e9acfff8a32f45fb.jpeg)  
after save.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 15, 2018, 8:01am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/13 "2018-08-15T08:01:09Z")

</div>

OK 2 questions…

1. If you go to a different user and upload this image as an avatar and pick it does it work?

 ![download](https://global.discourse-cdn.com/meta/original/3X/4/b/4b8a7b1cd5669d31405ad38562df55d6cf9e0554.jpeg)

1. If you go to the problem user and upload does it work?

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 15, 2018, 8:14am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/14 "2018-08-15T08:14:26Z")

</div>

1. For another user it is broken too 😑.  
 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/a/d/adfe8c12099d837d1c9edaa077d62a5e5b85b1b6.png)  
Avatar becomes grey:  
 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/5/4/541b098070c2d36344cf3ed67216a836ef4ab140.png)

```plaintext
Started POST "/discuss/uploads.json?client_id= ***&authenticity_token=***" for 62.69.*.* at 2018-08-15 08:03:19 +0000
Processing by UploadsController#create as JSON
  Parameters: {"type"=>"avatar", "user_id"=>"2189", "files"=>[#<ActionDispatch::Http::UploadedFile:0x00007f81c115a9b0 @tempfile=#<Tempfile:/tmp/RackMultipart20180815-225-17uact1.jpeg>, @original_filename="4b8a7b1cd5669d31405ad38562df55d6cf9e0554.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"files[]\"; filename=\"4b8a7b1cd5669d31405ad38562df55d6cf9e0554.jpeg\"\r\nContent-Type: image/jpeg\r\n">], "client_id"=>" ***", "authenticity_token"=>"***"}
  Rendering text template
  Rendered text template (0.0ms)
Completed 418 in 15ms (Views: 0.7ms | ActiveRecord: 2.9ms)

```

1. I’ve tried to upload the same cat to problem user’s avatar without success (the same behavoiur as in point 1 above).

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [August 15, 2018, 8:37am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/15 "2018-08-15T08:37:13Z")

</div>

Emm… Upgrading forum to [v2.1.0.beta4 +91](https://github.com/discourse/discourse/compare/243fc9d0f9b943d81c1a8ffb8d3e152f507b0ce6...tests-passed) resolved the issue.

Thanks everybody for help!

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [August 15, 2018, 8:38am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/16 "2018-08-15T08:38:57Z")

</div>

I guess the problem is that the current Docker image ships ImageMagick 7, but Discourse 2.0.3 was built for ImageMagick 6. There might be an incompatibility which prevents Discourse from successfully cropping the avatar.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 16, 2018, 1:53am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/17 "2018-08-16T01:53:52Z")

</div>

Oops sorry about this one. I’ve back-ported compatibility for ImageMagick 7 back to stable.

[https://github.com/discourse/discourse/commit/5778c33ee79da5b4fec377323e847a59b9b9a863](https://github.com/discourse/discourse/commit/5778c33ee79da5b4fec377323e847a59b9b9a863)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 15, 2018, 1:54am UTC](https://meta.discourse.org/t/how-to-fix-user-avatar/94675/18 "2018-09-15T01:54:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
