When a user uploads an image, I am able to use the wp_generate_attachment_metadata
hook to know about all the thumbnail locations.
When I use Wordpress to Edit Image (to scale, resize, etc), I can not figure a similar hook. If I hook to wp_save_image_editor_file
, I can do $metadata = wp_get_attachment_metadata($post_id);
which always gets me the previous iteration. So if I edit an image two times, $metadata
would contain the sizes of the last edit. Not the one that just completed.
I tried this code, but it doesn't even fire:
add_filter('wp_edited_image_metadata', 'edited_image_metadata', 10, 3);
function edited_image_metadata($new_image_meta, $new_attachment_id, $attachment_id)
{
error_log("EDITED FILE METADATA: $new_attachment_id | $attachment_id");
}