How to check the uploaded video TYPE in WordPress PHP?

Hello there!

I have a static code which supports videos for all browsers types.



Is there any video TYPE out there that will be supported by all browsers and if yes, how can i create a function
in WordPress in order to check what video type has been uploaded?

I have found this function:

<?php $filetype = wp_check_filetype('video.mp4'); echo $filetype['ext']; // output mp4 ?>

How can i fix this?


1 Like

Your best bet for cross browser/device compatibility is probably mp4, I’d guess? But not 100% sure.

That function is probably exactly what you’d want to use. Check it, and if it’s not the one you want, return an error from your form validation.

You also want to make sure you alert users to only upload your preferred format, before they do so, so you aren’t frustrating them with random refusals.


Yeah, great solution it is… i’v checked it mp4 is supported by all browsers only IE8 does not support it. But who cares… who uses IE8 anyway. Thanks for the tips.

Depends on your target audience I guess.

If the data can be trusted to be closely accurate, IE8 ~8%, though likely skewed by China where it’s ~34%

1 Like

If there was then it wouldn’t be necessary to list three types in the video tag in order to support all browsers.

1 Like

The only way to support all browsers is to provide the video in all supported formats. The best way to do that would be to use a library such as avconv to process the and convert the single video to multiple formats. However, on a shared hosting platform that is probably highly impractical. So unless you’re running dedicated server or are in the cloud you are limited to services external to the website itself that provide video processing capabilities.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.