You are here

function _video_get_filetype in Video 6.2

Same name and namespace in other branches
  1. 5 video.module \_video_get_filetype()
  2. 6 video.module \_video_get_filetype()
  3. 6.3 includes/common.inc \_video_get_filetype()

Pull the file extension from a filename

Parameters

$vidfile: string filename to get the filetype from.

Return value

string value of file type or boolean FALSE on error

2 calls to _video_get_filetype()
_video_common_get_player in includes/common.inc
Get the object for the suitable player for the parameter resource
_video_get_mime_type in ./video.module
Returns the correct mime-type for the video. Returns false if the mime-type cannot be detected.

File

./video.module, line 1279
video.module

Code

function _video_get_filetype($vidfile) {

  //If the filename doesn't contain a ".", "/", or "\" and is exactly 11 characters then consider it a youtube video ID.
  if (!strpos($vidfile, '.') and !strpos($vidfile, '/') and !strpos($vidfile, '\\') and strlen($vidfile) == 11) {
    $file_type = 'youtube';
  }
  else {
    if (strpos($vidfile, 'google:') === 0) {
      $file_type = 'googlevideo';
    }
    else {
      if (strstr($vidfile, '.')) {

        //If file contains a "." then get the file extension after the "."
        $file_type = end(explode('.', $vidfile));
      }
      else {
        $file_type = FALSE;
      }
    }
  }
  return strtolower($file_type);
}