Jump to content

Recommended Posts

Posted

I'm working on a little image resizing module that hooks in after the image was uploaded in the back end (based on Somas code).

But unlike Soma I use GD to generate the resized (and slightly modified image). So, before there are any questions: Yes I need to use GD instead of $image->size(...)

The resizing works but I would really like to add my variation (my resized image) to the $image->getVariations. First of all because I want to get my resized image to be deleted when the original image was deleted and second because of consistency reasons.

Simple question: How can I add my self-generated image to the PW-image variations?

Posted

This is something that I am sure horst will follow up on, but as far as I know, the only thing you need to do (or can do), is to make sure the filename matches the conventions for variations: https://github.com/ryancramerdesign/ProcessWire/blob/7b9730d43e6eda8bd27841a4811a1b9737bfe903/wire/core/Pageimage.php#L484

If you need a different filename format that isn't automatically detected by the core isVariation() method that I pointed to above, you can hook it and modify like I have done here: https://github.com/adrianbj/ImageRasterizer/blob/master/ImageRasterizer.module#L243

Hope that helps until our image expert sees this!

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...