I'm trying to run a little function to determine the luminance of an image and store that in the postmeta for that image..
I have the function working, but id like it to fire when an image has finished uploading.. does anyone know the function/filter/action i should hook into for this?
ive looked at
- image_attachment_fields_to_save
- attachment_fields_to_save
- wp_handle_upload
- media_upload_form_handler
- wp_generate_attachment_metadata
and i just cant seem to make any of them simply run an addition to the postmeta table for the image
currently my code looks something like:
function insert_luminance_data($post, $attachment) {
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
$lum = 'TEST';
add_post_meta( $post['ID'], 'image_lum', $lum, true ) || update_post_meta( $post['ID'], 'image_lum', $lum );
}
return $post;
}
add_filter('image_attachment_fields_to_save', 'insert_luminance_data', 10, 2);
but this isnt working.
Thanks in advance for any assistance