/**
* Inserts FLV Player button into media library popup
* @return the amended form_fields structure
* @param $form_fields Object
* @param $post Object
*/
function egmInsertFLVButton($form_fields, $post) {
global $wp_version;
$file = wp_get_attachment_url($post->ID);
// Only add the extra button if the attachment is an flv file
if ($post->post_mime_type == 'video/x-flv') {
$form_fields["url"]["html"] .= "";
if (version_compare($wp_version, "2.7", "<")) {
$form_fields["url"]["html"] .= "\n";
}
}
return $form_fields;
}
add_filter("attachment_fields_to_edit", "egmInsertFLVButton", 20, 2);
/**
* Format the html inserted when the FLV Player button is used
* @param $html String
* @return String
*/
function egmSendToEditor($html) {
if (preg_match("/([^<]*)<\/a>/i", $html, $matches)) {
$html = $matches[2];
if (strlen($matches[5]) > 0) {
$html = preg_replace("/]$/i", " 480 360]", $html);
}
}
return $html;
}
add_filter( 'media_send_to_editor', 'egmSendToEditor' );