[wp-trac] [WordPress Trac] #10530: Pass post-id to filters 'wp_generate_attachment_metadata'

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 1 10:49:23 UTC 2009


#10530: Pass post-id to filters 'wp_generate_attachment_metadata'
-----------------------------+----------------------------------------------
 Reporter:  stephanreiter    |       Owner:     
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  2.9
Component:  Media            |     Version:     
 Severity:  trivial          |    Keywords:     
-----------------------------+----------------------------------------------
 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;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10530>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list