You are here

private function MediaFile::getType in MediaFront 7.2

Returns the media type.

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

File

./MediaFile.php, line 166

Class

MediaFile

Code

private function getType() {

  // Get the mimetype.
  $parts = explode('/', $this->mimetype);
  $mimetype = $parts[0];

  // See if we are an image.
  $image = in_array($this->extension, array(
    'jpg',
    'jpeg',
    'png',
    'gif',
  ));
  $image |= $mimetype == 'image';
  if ($image) {
    return 'image';
  }

  // See if we are video.
  $video = in_array($this->extension, array(
    'mp4',
    'm4v',
    'flv',
    'f4v',
    'webm',
    'webv',
    'ogg',
    'ogv',
    '3g2',
    '3gpp',
    '3gp',
    'mov',
    'swf',
  ));
  $video |= $mimetype == 'video';
  if ($video) {
    return 'video';
  }

  // See if we are audio.
  $audio = in_array($this->extension, array(
    'oga',
    'mp3',
    'm4a',
    'f4a',
    'aac',
    'wav',
    'wma',
    'weba',
  ));
  $audio |= $mimetype == 'audio';
  if ($audio) {
    return 'audio';
  }
}