Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Allow optional cropping of images while uploading #65

Merged
merged 1 commit into from
May 19, 2016

Conversation

rogierslag
Copy link
Member

As requested by @wouter-willems, setting the query parameters x, y, width and height allow to crop the picture when uploading. This prevents cropping weirdness in the browser if we handle it using javascript

Ready for review @TiddoLangerak @joostverdoorn @wouter-willems

@wouter-willems
Copy link
Collaborator

Thank you! 👍

@@ -267,7 +267,7 @@ const Image = {
// Upload the RAW image to disk, stripped of its extension
// First check the token
const sentToken = req.headers['x-token'];
const matches = req.url.match(/^\/(.*)\.([^.]+)$/);
const matches = req.path.match(/^\/(.*)\.([^.]+)$/);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this change come from? Was this a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this did work because of the format and constraints in the past. But yes it was a possible bug ;)

The url contains the full URL, including any query parameters. These were not used in the past, so never sent. The url was therefore equal to the path.
Since we now do accept query parameters, we want to save the file as test.jpg and not test.jpg?x=0&y=4&width=100&height=400 but still as test.jpg. The path variable contains exactly this

@rogierslag rogierslag force-pushed the cropping-while-uploading branch from d3bd2f7 to 95e5952 Compare May 19, 2016 13:59
@rogierslag rogierslag merged commit 42845dd into develop May 19, 2016
@rogierslag rogierslag deleted the cropping-while-uploading branch May 19, 2016 14:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants