1

I just downloaded the manual crop module: https://www.drupal.org/project/manualcrop

It must be added as an image style effect before it is applied.

I would like to apply it to all image styles before others are executed.

Is there any hook_preprocess_image_style that can add an effect to the stack before others are processed?

Or anybody have any other good ideas about how to do this programmatically other than manually adding the style?

Thanks!

  • You confuse terms. Only one image style can be applied, so your title make no sense. On the other hand, one style can have any number of effects, and it's easy to reorder them with simple drag and drop: it's well documented, make sure you read it and play with it. – Mołot Aug 20 '15 at 19:49
  • I have corrected the title: thank you, I wrote it on the way out the door. Though your suggestion that I manually add the effect to each image style was precisely what I am trying to avoid. Rather, I want to add my effect programmatically, which I state quite clearly in the question. – Jeremy John Aug 21 '15 at 3:00
  • I meant playing to familiarize with names, not to give up programmatic solution. Sorry if I wasn't precise enough. – Mołot Aug 21 '15 at 6:21
  • You can control the order of effects at the image style admin UI. Is there a reason why what is not acceptable? Maybe there is another way to achieve your requirement that is easier. The main reason I can see for applying an effect programmatically is to apply it some of the time but not all of the time, or to modify its effects in some way some of the time. Both of those seem a bit risky since the images get cached in the way they are first generated so a single dynamic style may cause issues. – rooby Aug 31 '15 at 22:23
3

Yes, you can do this with hook_image_styles_alter.

I'm not so sure it's a great idea since you'll be enforcing adding your effect no matter what the user might try to configure via the interface, but it will definitely let you do what you want to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.