You must use this function wp_check_filetype
to check what is your media type
$filetype = wp_check_filetype('image.jpg');
echo $filetype['ext']; // will output jpg
then you can have something like this
$file_url = wp_get_attachment_url( $file_id );
$filetype = wp_check_filetype( $file_url );
switch ($filetype) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
return // do whatever you want
break;
case 'video/mpeg':
case 'video/mp4':
case 'video/quicktime':
return // do whatever you want
break;
case 'text/csv':
case 'text/plain':
case 'text/xml':
return // do whatever you want
break;
default:
return // do whatever you want
}
so in your function you can first check your attachment file type and when it’s Video you can do your redirect code.
for more information:
1- https://codex.wordpress.org/Function_Reference/get_post_mime_type
2- https://codex.wordpress.org/Function_Reference/wp_check_filetype
Hope it works for you.