Use JS to read image dimensions on upload #2705
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The issue
Some jpegs are taken in one orientation and then rotated on a device and exported such that the display of the image doesn't seem to match the dimensions. The result is you upload what you think is a portrait image but is actually a landscape image, which EXIF data set to rotate the image. This then gives un-expected results in the image cropping tool and on the front end.
The fix
Halt the fine-uploader by using a promise on the submit callback of fine-uploader, until after the image has loaded and JavaScript has had a change to grab the image dimensions. Previously the upload was completing before the image had been loaded and so image dimensions were not being sent.
And then we're using the supplied values from the front end when storing the values.