#10530 closed feature request (duplicate)
Pass post-id to filters 'wp_generate_attachment_metadata'
| Reported by: | stephanreiter | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Media | Version: | |
| Severity: | trivial | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Already in core: #10494 [11747]