Closed CowMuon closed 1 year ago
After some discussion, preference here is to go straight to .webp, unless there is an identified reason why not to.
Implementation:
compressImage
to always compress to .webpuseImageUploader
and useImageDropAndPaste
hooks to incorporate compressImage
.AvatarUpload
to use compressImage
.Based on discussions with @NakulManchanda and @kurtisassad, here is the situation:
We have an open PR that is an unfinished implementation of the cloudflare solution discussed in the parking lot. If we pursue this option, and it works (needs to be fully tested), the following things are true:
The benefits of instead going forward with this ticket as written (changing the upload situation, not changing the previously uploaded content):
The benefits of also going back through previously uploaded content and converting to .webp:
So I guess my question for you @MuonShot was what specifically was the impetus for writing this ticket? What are the specific things about either DevEx or site performance or costs we want improved? Answers to those questions will help determine whether we should move forward with this ticket as written or defer finishing to Kurtis' PR, or neither.
What decisions need to be made by today / tomorrow, or initial work on this will be blocked? IOW, what is the order of operations for executing scope of work here?
Key decisions, in order:
Can we get an update how far we got on this, and an estimate how far out (ie how many hours) we are from delivery on this? @alexyoung23j
[viz. to get this out the door tomorrow]
Set this to In Progress on the new board; I did see it got sent back to Teed Up, but without an explanatory comment.
Do not have the appropriate AWS permissions (or was added to the wrong org) to view our current buckets. Need this access to proceed.
Update!!
Just worked with @kurtisassad to get this ready to go. We did the following:
Next steps:
@MuonShot
@alexyoung23j Moved to has PR but no PR added under Development?
I have linked the PR now. Basically the CDN PR fixes this ticket as well as the CDN ticket.
It is finished but currently in draft while I wait for some staging environment to free up.
Still in draft because I would like to test it on staging before we review it. Unfortunately all staging envs are in use right now.
We will need an update to the team wiki documenting what changes were made in Cloudflare for compressed images along with any information how it was setup, expected ongoing concerns, troubleshooting, etc. @alexyoung23j @kurtisassad
Not closed until CDN settings are properly configured + documented.
@alexyoung23j One more issue: So I think it won't resize too large of images as per the Cf-Polished response header due to input_too_large. In this case it will not compress the image according to: The Cf Polished statuses doc
I think we need to handle image resizing for images larger than 1000 x 1000 manually, as well as add a cap to it in the upload logic.
But after these images are forced to be smaller than 1k x 1k, cloudflare's image compression/conversion will kick in automatically.
https://www.npmjs.com/package/browser-image-compression Potential package to use for client side compression.
@alexyoung23j what is the scope of work here that you have in progress = what exact steps are you planning on taking?
@jnaviask Since the other PR went in that included the bucket changes + cloudflare polish updates, the scope now is simply to ensure that all images uploaded are compressed to ensure that Cloudflare Polish (which automatically tries to converts all images to webp) is able to succeed as often as possible. If images are already uploaded or optimized on upload, Polish does nothing, but based on this page in their docs, images should be less than 10mb and have a maximum height or width or 1000px in order for Polish to be used most often. So I will have a PR up in a few minutes that uses a package browser-image-compression to ensure those constraints before we upload to s3. I don't really understand what @CowMuon was getting at on the call today- hopefully this answers the question you had.
If images are already uploaded or optimized on upload,
What exactly does it mean for images to be "already uploaded on upload"? @alexyoung23j
@MuonShot ah just meant that Polish may not work on images that are already in the bucket, if they are larger than the constraints. After this PR goes in, newly uploaded images will all be compatible with Polish
Problem
Images added to the app (via a number of vectors) are not being compressed or otherwise handled in an efficient manner. This is happening in a number of places including the forum, & user profiles & adding community icons, that later of which was significantly reworked a while back by @kurtisassad.
Moreover we need to have a unified approach here that we extend for each use case, rather than a collection of one off tickets such as linked above.
Engineering Requirements
Acceptance Criteria
Additional considerations