This is a module gives the site admin the ability to apply different image styles to an image controlled with rules, among probably other stuff.
It does so by providing a new image effect that invokes a rules event, and by using conditions and actions also provided by this module, you can, based on certain conditions, apply any other image style.
I made this module in an attempt to have a flexible way of having alternative image styles apply to one same formatter.
This is not a simple module and I assume you know a fair bit of both image styles and rules. Please do not add support issues into how to use either of those modules.
Usage of the module
- Install the module as usual.
- Creates a new image style.
- Add the "Invoke a rules event" effect to the image style.
- Create a new rule for the "Image style rules effect is being applied" event.
- Adds the condition "Image style being used" and select the image style you just created. This is only useful if you have different image style that invokes the rule effect.
- Adds the action "Use an image style" and select the image style you want to be applied.Make sure it's different from the one you just created.
At this point, you should have a functional image style that applies the effects of the image style you selected in rules. Yes, I know, you could have done this by just using that one image style, but...
You can now add more conditions exposed by this module (or any other that you may think of):
- Image style being used
- Width comparison
- Height comparison
- Aspect ratio comparison
And play around with those values to only apply the selected style in the action above when certain conditions are met.
You can then create another rule for the same event, add a different set of conditions and choose a different image style to be applied.
Example use case
In my particular case, I have products that have very different aspect rations, some pictures have regular aspect ratio while others are too tall and narrow. Using the same image style for every picture would end with a too much cropped image or a too small image depending which one I try to give priority to.
With this module installed I can define a new image style that invokes a rule that allows me to apply different image styles based on the image's aspect ratio.
Of course, because of rules, you can add/use any other number of conditions and actions allowing for a lot of flexibility and probably match some other use cases.
This could have been accomplished by coding it in the theme, probably a lot quicker, but was a fun module to code.
Contribute back
If you like the module, if you find it useful, and/or if you just want to contribute to this module development, please feel free to do so with PayPal. I will appreciate it.
I try to contribute as many modules as I can as soon as I am in the need for a new functionality that can be re-used by others. A lot of times, doing the module for others means a lot more time that if I were to do it just quick and dirty, but I like both the challenge and the process. I also try to maintain them on my spare time as time gets available.
You can also support the Drupal project as well, information is in their project page.
Project information
34 sites report using this module
- Created by hanoii on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
