function MimeTypeGuesser::guessMimeType
Same name in this branch
- 9 core/lib/Drupal/Core/ProxyClass/File/MimeType/MimeTypeGuesser.php \Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guessMimeType()
Same name in other branches
- 10 core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php \Drupal\Core\File\MimeType\MimeTypeGuesser::guessMimeType()
- 10 core/lib/Drupal/Core/ProxyClass/File/MimeType/MimeTypeGuesser.php \Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guessMimeType()
- 11.x core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php \Drupal\Core\File\MimeType\MimeTypeGuesser::guessMimeType()
- 11.x core/lib/Drupal/Core/ProxyClass/File/MimeType/MimeTypeGuesser.php \Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guessMimeType()
1 call to MimeTypeGuesser::guessMimeType()
- MimeTypeGuesser::guess in core/
lib/ Drupal/ Core/ File/ MimeType/ MimeTypeGuesser.php
File
-
core/
lib/ Drupal/ Core/ File/ MimeType/ MimeTypeGuesser.php, line 55
Class
- MimeTypeGuesser
- Defines a MIME type guesser that also supports stream wrapper paths.
Namespace
Drupal\Core\File\MimeTypeCode
public function guessMimeType(string $path) : ?string {
if ($wrapper = $this->streamWrapperManager
->getViaUri($path)) {
// Get the real path from the stream wrapper, if available. Files stored
// in remote file systems will not have one.
$real_path = $wrapper->realpath();
if ($real_path !== FALSE) {
$path = $real_path;
}
}
if ($this->sortedGuessers === NULL) {
// Sort is not triggered yet.
$this->sortedGuessers = $this->sortGuessers();
}
foreach ($this->sortedGuessers as $guesser) {
$mime_type = $guesser->guessMimeType($path);
if ($mime_type !== NULL) {
return $mime_type;
}
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.