How can we change image resolution with the URL name?

The following site is using some type of image resizing system where if you change the number 570 near the end of the URL it changes resolution to that size of image.

https://i.etsystatic.com/17880379/r/il/ac007d/2265875889/il_570xN.2265875889_sijr.jpg

Does anyone know how they might be doing this and if it is possible in MODx?

You can do something like this by rewriting the request URL.

You could for example convert the URL

https://yourdomain.com/yourpage/570xSomeImage.jpg

to

https://yourdomain.com/yourpage?&width=570&image=SomeImage.jpg

and then run a script on the page “yourpage” that generates a thumbail of the image “SomeImage.jpg” with a width of 570 and returns it.


In MODX the rewrite is usually done by creating a plugin that runs on the event OnPageNotFound where you parse the URL, set the request parameters and forward the request to the correct resource.

1 Like