tomaszsita / wp-manual-image-crop

Repository of WordPress image cropping plugin http://wordpress.org/plugins/manual-image-crop/
67 stars 40 forks source link

Add filters and actions #46

Open rdebeasi opened 8 years ago

rdebeasi commented 8 years ago

I've added a few filters to the plugin so that other plugins can interact with it. I think this should address the request in #37. @firejdl has added an action that runs when the crop is done. This change solves issue #25.

My text editor also removed some space at the ends of lines, for some reason.

Anyway, I'd love to hear your thoughts! Feel free to let me know if you'd like to see any changes or if this can be merged as-is. Manual Image Crop rocks - thanks so much for developing it!

filters

mic_do_crop

Provides $do_crop (bool), $metadata (array), and $dims (array). Returning false for $do_crop will prevent Manual Image Crop from cropping the image. $metadata contains the crop parameters, so another plugin can take over the actual cropping.

mic_dst_file_path

Provides $path (string) and $data (array). Manual Image Crop will write the new image to $path and save that path to the image metadata. $data contains the crop parameters that the user chose in WordPress admin.

mic_dst_file_url

Provides $url (string) and $data (array). Manual Image Crop will return $url in an AJAX response if the image crop is successful. $data contains the crop parameters that the user chose in WordPress admin.

actions

mic_crop_done

Triggered after a crop has been successfully completed, immediately before the JSON response is sent to the browser. Provides $data (array) and $imageMetadata (array).