hdesigns Posted January 31, 2015 Posted January 31, 2015 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?
adrian Posted January 31, 2015 Posted January 31, 2015 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! 2
hdesigns Posted January 31, 2015 Author Posted January 31, 2015 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 I'd never thought it could be so easy. But it is! Thanks adrian!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now