Skip to content
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

Query string parameters (wordpress support) #19

Open
dciphered opened this issue Nov 27, 2023 · 2 comments
Open

Query string parameters (wordpress support) #19

dciphered opened this issue Nov 27, 2023 · 2 comments

Comments

@dciphered
Copy link

Hi all,

I have a question regarding the query string parameters that are being passed for image transformations. On inspection of the cloudfront function, it appears as though the optimizer supports 4 query string parameters for performing image transformations (format, width, height and quality). The issue that I'm experiencing is that frameworks such as Wordpress have specific parameters that are used in image URLs, for example 'h' and 'w' for height and width respectively, which doesn't get parsed by the CF function. Other query string parameters that typically get used by image optimization CDN's include 'q' for quality, 's' for security keys, etc..

In short, anyone attempting to implement this image optimization solution on a wordpress site won't have any luck doing so unless the URIs are constructed/transformed appropriately on the web server before the image is called via the optimizer CF distribution (which isn't currently viable).

Is there a simple way to achieve this? Essentially, the requirement would be to transform the below sample URL (the first being a wordpress image url with transformation parameters) into one that can be properly interpreted by the image optimizer (second sample url):

  1. Wordpress URL which includes dimensions and other image optimizer query strings (supported by Imigix, etc.):
    hxxp://sample-image.jpg?q=50&h=500&w=500&s=123456789

  2. URL that AWS image-optimizer expects:
    hxxp://sample-image.jpg?format=auto&height=500&quality=50&width=500

Assuming the answer will require modifying the cloudfront function (and maybe a lambda function or functions)...

Alternatively (and possibly a big ask) but having a co-pilot wordpress plugin developed that would do exactly this for image URLs would be the best solution by far, avoiding having to spin up a custom branch for maintaining this stack to achieve image optimization for wordpress websites.

Many thanks and I look forward to your reply.

@achrafsouk
Copy link
Contributor

Hello,

As you figured out, it's simply possible by changing the CloudFront Function, notably the case switches:
case 'width': -> case 'w':

Thanks for the feedback regarding a wordpress plugin, it's noted.

@chrillep
Copy link

chrillep commented Mar 7, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants