-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Resize images #876
base: develop
Are you sure you want to change the base?
Resize images #876
Conversation
I just noticed that this does no longer go through the |
# Specify cookies SameSite protection level: either :none, :lax, or :strict. | ||
# | ||
# This change is not backwards compatible with earlier Rails versions. | ||
Rails.application.config.action_dispatch.cookies_same_site_protection = nil |
Check notice
Code scanning
Weak cookie configuration
Looks good to merge once #854 is in. |
Rather than serving potentially really big avatars, resize them to fit in the indicated avatar size.
c0d9814
to
2d261c9
Compare
@MoshiKoi This alters the permanent redirect behavior to s3 that is currently present (4c05959). If we want to keep that the variant would need to be created up front and sent to s3. |
The permanent redirects were put into place because the image requests were disproportionately slow. Investigate the timings to see if this is still the case. |
Images were not being resized, even when displayed as tiny 40x40 squares. For codidact, the image size limit is 2 MB which somewhat alleviates this problem, but for our self hosted instance we upped max image size to 10 MB for posts (which also affects avatars). As a result, if someone uploads a 6 MB avatar, any page which displays it loads the 6 MB giant avatar and then the browser has to scale it down to display it as a tiny image. This causes huge load times and server traffic for pages like the users overview.
In this PR, images are resized by ActiveStorage to the size matching the requested size (without altering aspect ratio). These resized images are created once when requested and are then cached on the storage provider (in your case, Amazon AWS) and not resized again.
As a bonus, images are also upscaled to the requested size if they are smaller, which should resolve #462 and ensure equal image size for all users.
Finally, the profile page would not maintain aspect ratio of the image (in contrast to all other locations which display the avatar). This is fixed in 879040d.
Fixes #462
Fixes #1133