How to fix user avatar?

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
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

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

Thank you, @gerhard!

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

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?

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

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

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

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

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

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.

2 Likes

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.

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 :slight_smile: . The file in /tmp folder already has deleted.

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

I can go to the user profile. I can change an avatar to %D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5 only. I can choose another options, gravatar and custom picture (custom picture even is shown in preview), but they always change to %D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5 after save.

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

  1. If you go to the problem user and upload does it work?
  1. For another user it is broken too :expressionless:.
    %D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5
    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
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).

Emm… Upgrading forum to v2.1.0.beta4 +91 resolved the issue.

Thanks everybody for help!

1 Like

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.

6 Likes

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

https://github.com/discourse/discourse/commit/5778c33ee79da5b4fec377323e847a59b9b9a863

7 Likes

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