You are here

private function MediaFile::getMimeType in MediaFront 7.2

Returns the mimetype.

1 call to MediaFile::getMimeType()
MediaFile::__construct in ./MediaFile.php

File

./MediaFile.php, line 109

Class

MediaFile

Code

private function getMimeType($file) {
  if (!empty($file->filemime)) {
    return $file->filemime;
  }
  if (!empty($file->mimetype)) {
    return $file->mimetype;
  }

  // Or just go off the extension.
  switch ($this->extension) {
    case 'png':
    case 'jpeg':
    case 'jpg':
    case 'gif':
      return 'image/' . $this->extension;
    case 'mp4':
    case 'm4v':
    case 'flv':
    case 'f4v':
      return 'video/mp4';
    case 'webm':
    case 'webv':
      return 'video/webm';
    case 'ogg':
    case 'ogv':
      return 'video/ogg';
    case '3g2':
      return 'video/3gpp2';
    case '3gpp':
    case '3gp':
      return 'video/3gpp';
    case 'mov':
      return 'video/quicktime';
    case 'swf':
      return 'application/x-shockwave-flash';
    case 'oga':
      return 'audio/ogg';
    case 'mp3':
      return 'audio/mpeg';
    case 'm4a':
    case 'f4a':
      return 'audio/mp4';
    case 'aac':
      return 'audio/aac';
    case 'wav':
      return 'audio/vnd.wave';
    case 'wma':
      return 'audio/x-ms-wma';
    case 'weba':
      return 'audio/webm';
    default:
      return '';
  }

  // Return nothing.
  return '';
}