Allow DI on ImageTransform#15646
Merged
brandonkelly merged 10 commits into5.6from Jan 11, 2025
Merged
Conversation
timkelty
commented
Sep 3, 2024
2 tasks
anhtai9710
approved these changes
Oct 27, 2024
Contributor
|
@timkelty Finally got round to testing this and it's perfecto! I forked the 5.x branch and rebased your changes on top. Everything worked fine. This looks like a simple enough change it could be merged into Craft 4 as well? |
Contributor
|
@timkelty What's needed to get this merged :) |
Contributor
|
@timkelty I had another play with this PR and I can reduce it to just removing the filtering on the I can pass through the behaviours custom property by using the Event::on(
ImageTransform::class,
Model::EVENT_DEFINE_FIELDS,
function (DefineFieldsEvent $event) {
$event->fields['imgixParams'] = 'imgixParams';
}
); |
Contributor
|
Yewww! |
Member
|
Craft 5.6.0 is out now 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Description
The goal is to allow developers to write an
ImageTransformerthat builds URLs using properties other than those included in\craft\models\ImageTransform, egblur.This PR does 2 things:
createObjectso\craft\models\ImageTransformcan be customized through DI.\craft\models\ImageTransform::toArraywithout any args, so that all properties are returned.Related issues
#15062
Example usage
Module/Plugin
Template
{% set transform = { mode: 'crop', width: 100, height: 100, quality: 75, blur: 40, } %} {% set asset = craft.assets().one() %} {{ asset.getUrl(transform) }} {{ asset.getImg(transform, ['1.5x', '2.0']) }}