Get attachment id within wp_generate_attachment_metadata filter
-
I’m trying to amend image attachment meta on upload by hooking into the wp_generate_attachment_metadata filter:
add_filter('wp_generate_attachment_metadata','updateExif_uploaded_image');
function updateExif_uploaded_image($image_data) { // do stuff ... wp_update_attachment_metadata( $attachment_id, $image_data); return $image_data; }
While “do stuff” works, I’m having trouble actually updating/saving the meta data as from what I can see, the attachment id is not passed into this function.
From
/wp-admin/includes/image.php
I can see that the ID is passed as a parameter but how do I get that from my function?I tried
function updateExif_uploaded_image($image_data, $attachment_id)
but this caused an error with incorrect number of parameters.Thanks in advance
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get attachment id within wp_generate_attachment_metadata filter’ is closed to new replies.