You are here

public function AssetImageHelper::getMimeTypeFromFileType in Media: Acquia DAM 8

Get MIME type information based on a file extension.

Parameters

string $fileType: The file extension to get information for.

Return value

array|false The MIME type information or FALSE on failure.

1 call to AssetImageHelper::getMimeTypeFromFileType()
AssetImageHelper::getThumbnail in src/Service/AssetImageHelper.php
Get the thumbnail for the given asset.

File

src/Service/AssetImageHelper.php, line 189

Class

AssetImageHelper
Class AssetImageHelper.

Namespace

Drupal\media_acquiadam\Service

Code

public function getMimeTypeFromFileType($fileType) {
  $fake_name = sprintf('public://nothing.%s', $fileType);
  $mimetype = $this->mimeTypeGuesser
    ->guess($fake_name);
  if (empty($mimetype)) {
    return FALSE;
  }
  list($discrete_type, $subtype) = explode('/', $mimetype, 2);
  return [
    'discrete' => $discrete_type,
    'sub' => $subtype,
  ];
}