Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification emails should use resized avatars #2625

Closed
mbethke opened this issue May 13, 2020 · 9 comments
Closed

Notification emails should use resized avatars #2625

mbethke opened this issue May 13, 2020 · 9 comments

Comments

@mbethke
Copy link

mbethke commented May 13, 2020

I just received a notification email for a reply to a changeset comment with an attached 8 MB avatar picture. Apparently the avatars are properly resized for display on the webpage but stored and sent in full resolution. While it might make sense for future adaptation to very high-res screens to store a somewhat higher resolution than the 100x66 or whatever that is usually shown, that seems a bit excessive. Avatars should be resized to something like 320x240 on upload.

@tomhughes
Copy link
Member

They are resized - we keep three versions I think.

The bug here is that the wrong version is used on the email not that we don't resize them.

@tomhughes tomhughes changed the title Avatars should be resized on upload Notification emails should use resized avatars May 13, 2020
@tomhughes
Copy link
Member

I assume this was an OSM hosted avatar by the way? Obviously the story is a bit different for gravatar hosted avatars.

@tomhughes
Copy link
Member

Hmm - it is supposed to use the 50x50 version: https://github.com/openstreetmap/openstreetmap-website/blob/master/app/mailers/notifier.rb#L192

Can you identify the user whose avatar caused the problem?

@mbethke
Copy link
Author

mbethke commented May 13, 2020

Sure, that was Dimesh from changeset 84683636. I'm not sure how Gravatars are delivered but I suppose they'd come directly from their servers - here you can still see in the URL that he originally uploaded a digicam picture unmodified.

@tomhughes
Copy link
Member

Thanks - ignore the gravatar comment. In turns out we don't attach those anyway.

@mbethke
Copy link
Author

mbethke commented May 13, 2020

I just checked the file from the mail again; it's really a verbatim digicam photo, 4000x3000 resolution with all the EXIF tags in, likely completely unprocessed as I suppose one would have to explicitly copy over the EXIF stuff then.

@tomhughes
Copy link
Member

Yes it appears that asking for the blob of a variant actually gets you the original image not the resized version:

irb(main):005:0> u.avatar.variant(:resize => "50x50>").blob
=> #<ActiveStorage::Blob id: 17138, key: "gVCyCqBtcEZgv6TGpPtbyK7Q", filename: "DSC_0518.JPG", content_type: "image/jpeg", metadata: {"identified"=>true, "width"=>6000, "height"=>4000, "analyzed"=>true}, byte_size: 6219460, checksum: "3zLkl1qlvCuxWgDelFXIGA==", created_at: "2019-07-15 19:27:36">
irb(main):006:0> u.avatar.blob
=> #<ActiveStorage::Blob id: 17138, key: "gVCyCqBtcEZgv6TGpPtbyK7Q", filename: "DSC_0518.JPG", content_type: "image/jpeg", metadata: {"identified"=>true, "width"=>6000, "height"=>4000, "analyzed"=>true}, byte_size: 6219460, checksum: "3zLkl1qlvCuxWgDelFXIGA==", created_at: "2019-07-15 19:27:36">

@tomhughes
Copy link
Member

I think https://stackoverflow.com/a/53965763/805631 is the solution.

@tomhughes
Copy link
Member

See also rails/rails#33037.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants