I’m using a function to create additional fields on media upload. They are important only for images and videos, but useless and even confusing to my users if they are uploading audio.
This is the function:
function give_linked_images_data($html, $id, $caption, $title, $align, $url, $size, $alt="" ){
$classes="img image-link";
if (get_post_meta($id, "pop_title") == '') $poptitle=""; else $poptitle=" data-title="". get_post_meta($id, "pop_title", true) .'"';
$html = preg_replace('/(<a.*?)>/', '$1 data-toggle="lightbox" '. $poptitle .' ' . $classes . '" >', $html);
return $html;
}
The functions is added with
add_filter('image_send_to_editor','give_linked_images_data',10,8);
…and I have a similar function using
add_filter('media_send_to_editor','give_linked_images_data',10,8);
…but it runs on video and audio upload. How can I detect if the media being uploaded is audio, to disable the custom fields?