WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In WP 3.4.x and earlier, it was possible to add a button to the media manager by messing around in an attachment_fields_to_edit filter. For example, a plugin could, when it figured out that an item was an audio file, append some HTML for an extra button to the url field, like so.

 $playertag = "[audio $url]";
 $fields['url']['html'] .= 
      "<button type='button' class='button data-link-url='$playertag' urlaudioplayer audio-player-$postid'>Audio Player</button>"; 

The new media manager has changed the set of buttons that were in that html tag into a pulldown menu -- a <select .../> item. The html code is emitted in media-template.php. The new code still calls attachment_fields_to_edit filters, but doesn't pass in any fields.

Is there a way to extend this select item without hacking the core (which I won't do). Is it conceivable to write a bit of js which will use jQuery to add an item to it?

share|improve this question
I read this question five times and still don't get around what exact buttons you're talking about. Could you please edit the question or add a screenshot? Thanks. – kaiser May 9 '13 at 16:48

Yes, it's possible in the same manner as before. I don't know why you think the filter is not passing the parameters anymore.

add_filter('attachment_fields_to_edit', 'user16975_edit_fields', 10, 2);
function user16975_edit_fields($form_fields, $attachment){

    // check for an audio attachment
    if ( substr($attachment->post_mime_type, 0, 5) == 'audio' ) {
        $playertag =  $playertag = "[audio ".wp_get_attachment_url($attachment->ID)."]";
        $form_fields["audioplayer"] = array(
            "label" => "Audio player",
            "input" => "html",
            "html" => "<button type='button' class='button' data-link-url='$playertag' audioplayer='audio-player-{$attachment->ID}'>Audio Player</button>",

    return $form_fields;

Here is the result :

Audio player button

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.