[wp-hackers] Simplifying media-upload.php reuse in custom metaboxes

Adam van den Hoven adam at littlefyr.com
Wed Aug 18 07:29:51 UTC 2010

Hey guys,

I've been hacking around trying to get the media library to work well with
custom meta boxes. Specifically, I want to pass modify the form fields that
show up for the media items to only provide the size selectors and to only
allow sending the URL for the chosen size to a piece of javascript that will
update the meta box accordingly.

To this end, I've made the following change in wp-admin/includes/media.php

<   $form_fields = apply_filters('media_upload_media_item_form_fields',

I'm terrible at picking good names but basically I want a filter that lets
me manipulate the field items for each before it gets written out. I can
then add arbitrary parameters to the query string and get it to do what I

Initially I tried defining get_media_item in my functions.php but PHP
complained about redefining the function (I'm not a PHP guy), so I modified
the core function. Clearly not going to survive the next incremental update.

Is there a more robust way to make this change or do I need to submit this
as a patch?


More information about the wp-hackers mailing list