How to extend LINK TO functionality in ATTACHMENT DISPLAY SETTINGS

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 = "";
        $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

Leave a Comment