-
-
Notifications
You must be signed in to change notification settings - Fork 124
Crop avatars with Imgproxy #2074
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
Conversation
b9096a6
to
71dccb1
Compare
I'd guess this works fine but I'm having trouble QAing in the normal dev setup. It returns a url with Do I need to modify my env or something? |
const IMGPROXY_URL = process.env.IMGPROXY_URL_DOCKER || process.env.NEXT_PUBLIC_IMGPROXY_URL
Since I tested it with HTTPS I just blanked the docker env var and used the public Imgproxy url. Basically docker containers can't use localhost with each other, they have to use hostnames instead. But this is actually a thinking error because the upload happens client-side so it might be appropriate to return a |
I get a CORs issue now with the default sndev setup.
|
Looks like we need to set |
Looks like we've had a bug with avatars in For future stuff, it's important our changes work in our common development environment. |
I honestly disregarded any CORS issue in dev because by running it on HTTPS I kinda expected to receive all kinds of errors. My bad for not looking into it.
Agree! Will be more careful towards dev env experience |
No worries! It's hard to appreciate these things - and just easy for me to which is I mentioned it. |
Description
Fixes #1778
Client-side cropping wasn't giving the best of results, this PR introduces cropping via Imgproxy's Crop feature giving better cropping results.
Screenshots
This keyboard pic zoomed at 250% from 200x200 makes a huge case for server-side processing
Additional Context
It required minimal changes, now React Avatar Editor is only used to get cropping values. With them we can now upload the untouched image to S3 safely and create an Imgproxy path to crop it.
We then upload the cropped image back to S3. This is a standard approach that imo could be better than serving imgproxy urls on avatars since if imgproxy goes down, every avatar would go down. It also fits nicely with already existing avatars and db schema.
Checklist
Are your changes backwards compatible? Please answer below:
Yes, it uploads the Imgproxy cropped photo back to S3 to also retain the existing setPhoto
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7, consistent good results
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a
Did you introduce any new environment variables? If so, call them out explicitly here:
n/a