servdhost / craft-asset-storage

MIT License
10 stars 1 forks source link

Feature/respect upscaleimages config #74

Closed therealpecus closed 9 months ago

therealpecus commented 11 months ago

This code patches the ImageTransforms class to respect the upscaleImages configuration when passing parameters to the CDN for on-the-fly transforms.

It ensures that, when both width and height are provided, the desired aspect ratio is mantained, constraining the transform dimensions within the maximum size of the original image.

You might want to review the code style (I am not a versed PHP developer). I tested this in a few use cases and it works as expected.

note/edit:

  1. the dpr parameter does not seem to be supported by the transform service API (assuming it is bunny-cdn), but if it is, it needs to be checked against in the function that calculates the maximum image size.
  2. this patch does not apply to Imager/ImageOptimize integrations

closes #73

mattgrayisok commented 9 months ago

Just added a slightly different implementation of this which should reduce the computations performed and also respect per-transform upscale settings. Will be released today.

Thanks for nudging us to add this in 👍