add_attachment
runs right after an attachment is added to the DB, but but before the metadata is generated. If you don’t need the value to be in the database yet, you can use the wp_generate_attachment_metadata
filter to hook in. However, if you need the data to be in the database already, you’ll have to use updated_post_meta
and check that the meta_key
passed in equals _wp_attachment_metadata
.