vollyimnetz / crop-thumbnails

"Crop Thumbnails" made it easy to get exacly that specific image-detail you want to show. Crop your images the simple way.
GNU General Public License v3.0
47 stars 21 forks source link

[Dev] Added filter 'crop_thumbnails_new_size_metadata' #78

Closed victormattosvm closed 1 year ago

victormattosvm commented 1 year ago

This filter allows changing the generated metadata of the cropped file.

It was useful for me when I needed to append metadata for the active size right after cropping.

vollyimnetz commented 1 year ago

@victormattosvm why was the "crop_thumbnails_before_update_metadata" filter not suitable?

victormattosvm commented 1 year ago

@victormattosvm why was the "crop_thumbnails_before_update_metadata" filter not suitable?

Hello @vollyimnetz Because this filter runs after the loop, sending all the attachment metadata, not just the image size being cropped. I needed to append metadata only for the active image size after the crop and after the metadata was generated.

vollyimnetz commented 1 year ago

@victormattosvm thank you for your contribution. I just want to let you know: the filter will be in for version 1.7.0 - but there will be slight changes, to make it more versatile. You shouldn't have much trouble to adapt your code.

From the upcoming documentation:

FILTER crop_thumbnails_after_save_new_thumb

This filter is called for every image-size after the crop of the image has been performed. It contains all of the modified metadata. With $imageMetadata['sizes'][$imageSizeName] you may access the last changed value.

Parameters:

victormattosvm commented 1 year ago

Cool! Thanks @vollyimnetz Even better.