Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#10530 closed feature request (duplicate)

Pass post-id to filters 'wp_generate_attachment_metadata'

Reported by: stephanreiter's profile stephanreiter 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)

#1 @azaozz
16 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Already in core: #10494 [11747]

#2 @Denis-de-Bernardy
16 years ago

  • Milestone 2.9 deleted
Note: See TracTickets for help on using tickets.