[wp-hackers] Editing media item fields

Adam van den Hoven adam at littlefyr.com
Fri Aug 27 04:30:15 UTC 2010

In a previous question I posted, Andrew Nacin gave the following advice:

In get_media_item(), $form_fields gets set like this:

$form_fields = get_attachment_fields_to_edit( $post, $errors );

In get_attachment_fields_to_edit(), you'll see a filter designed to
> modify/add fields.

So I had a look and low and behold the  line in question is:

$form_fields = apply_filters('attachment_fields_to_edit', $form_fields,

Since all I want is to select the URL a media Item and return it to the
calling page, I want to pull everything out and put in a single button.

I figure its always good to test stuff first (plus things didn't work the
way I expected) so I put in the following code in functions.php:

function hack_media_item_form_fields( $form_fields, $post ) {
    return array();
add_filter('attachment_fields_to_edit', 'hack_media_item_form_fields',1,2);

Something should have happened but nothing did. I then running the same
against media_upload_media_item_form_fields.

Does anyone have any idea what I'm doing wrong?

More information about the wp-hackers mailing list