#10530 closed feature request (duplicate)
Pass post-id to filters 'wp_generate_attachment_metadata'
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | trivial | Version: | |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
wp_generate_attachment_metadata filters currently only receive the metadata array, which doesn't contain any link to the representation of the uploaded image in the database. Although it's possible to retrieve the post-id via the following code in a hackish, probably error-prone way, I'd be better (and trivial) to supply the post-id as a parameter to filters.
function get_postid_from_metadata($metadata) { global $wpdb; $post = $wpdb->get_row($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_value = %s LIMIT 1", $metadata['file'])); return ($post != null) ? $post->post_id : FALSE; }
Change History (2)
Note: See
TracTickets for help on using
tickets.
Already in core: #10494 [11747]