public function ExtensionMimeTypeGuesser::convertMimeTypeToMostCommonExtension in FileField Sources 8
Same name in this branch
- 8 src/File/MimeType/ExtensionMimeTypeGuesser.php \Drupal\filefield_sources\File\MimeType\ExtensionMimeTypeGuesser::convertMimeTypeToMostCommonExtension()
- 8 src/ProxyClass/File/MimeType/ExtensionMimeTypeGuesser.php \Drupal\filefield_sources\ProxyClass\File\MimeType\ExtensionMimeTypeGuesser::convertMimeTypeToMostCommonExtension()
Convert mime type to most common extension.
Parameters
string $mimetype: Mime type.
Return value
string|bool Return extension if found, FALSE otherwise.
File
- src/
File/ MimeType/ ExtensionMimeTypeGuesser.php, line 39
Class
- ExtensionMimeTypeGuesser
- Add methods to core guesser.
Namespace
Drupal\filefield_sources\File\MimeTypeCode
public function convertMimeTypeToMostCommonExtension($mimetype) {
$this
->checkDefaultMapping();
$extension = FALSE;
if (isset($mimetype)) {
// See if this matches a known MIME type.
$mime_key = array_search($mimetype, $this->mapping['mimetypes']);
if ($mime_key !== FALSE) {
// If we have a match, get this list of likely extensions. For some
// reason Drupal lists the "most common" extension last for most file
// types including php, jpg, and doc.
if ($extensions = array_keys($this->mapping['extensions'], $mime_key)) {
$extension = end($extensions);
}
}
}
return $extension;
}