Add the ability to pass params through to the underlying ImageService #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been really enjoying using Twill Image - it's made managing images within a site so much easier!
However while using it I came a cross a couple of things that couldn't be achieved with Twill Image due to the inability to pass parameters to the ImageService.
In one instance instance I wanted to greyscale an image and the the other, possibly more common use case would be to amend the quality of the image. When handling large banner images and high-density screens I tend to adjust the image quality down on the larger images for hiDPI screens as the density covers up the lower quality and it means a much smaller image can be delivered. reference
This PR adds the ability to pass a params array through the Image model to the ImageService
You can also add the params array into the preset array in
twill-image.php
It is also possible to pass the params via the sources array too - this allows for different params (quality settings) per media query.
This is tested as far as my use case goes - so this may not be feature-complete, and I expect it may require further work. But this was just a quickly put-together PR to see whether this is something you'd want in the library.