I want the image resize option at the end of the cloudfront URL
Closed this issue · 5 comments
Now iam resizing the s3 bucket object using the following URL :-
https://d1l8km4g5s76x5.cloudfront.net/fit-in/200x200/IMG_7326.JPG
But now i want the /fit-in/200x200/ at the end of the URL like the following URL :-
https://d1l8km4g5s76x5.cloudfront.net/IMG_7326.JPG/fit-in/200x200
https://cdn.asp.events/CLIENT_Dubai_Wo_4B15F265_5056_B739_54F3125D47F0BC95/sites/cabsat-2023/media/CABSAT-2023-Master-Creative-For-WEB.jpg/fit-in/500x300
Please let me know what needs to be done so this work ?
@Shivam-Patil-groots It may be possible to do this using the existing REWRITE feature where a regular expression and replacement are used to reformat the incoming request to the expected path currently supported for thumbor style requests.
More detail on REWRITE is at https://docs.aws.amazon.com/solutions/latest/serverless-image-handler/rewrite-feature.html.
We tried a few tests and almost had it working for what you wanted. We will look more closely and get back to you.
Hello @dougtoppin
Please provide us code with image filter at the end of the cloudfront URL like following :-
https://d12cxtpsz7zucd.cloudfront.net/Screenshot_10.png/fit-in/100x100/
We tried to change the code but we are not able to achieve the goal.
Please look into this and provide us a solution as soon as possible
@dougtoppin Can you share with me how you tested these URLs using the rewrite feature? If you used a regex in REWRITE, could you please share it with me?
I had success with the following REWRITE_MATCH_PATTERN and REWRITE_SUBSTITUTION
Let me know if these work for you:
REWRITE_MATCH_PATTERN = /^\/(.*?\..*?)\/(.+)$/gm
REWRITE_SUBSTITUTION = /$2/$1
This will match the image name in any request you send in group 1, alongside the rest of the request in group 2, then swap their order before sending it to be interpreted.
Thanks,
Simon
Marking as resolved, let me know if you continue to have any issues