Task #46777
closed
Improve behaviour when mime type detection is missing
Added by Andreas Wolf almost 12 years ago.
Updated about 9 years ago.
Category:
File Abstraction Layer (FAL)
Description
When no library is available for doing mime type detection, information like the dimensions of images is not indexed. This leads to several problems e.g. in the frontend output.
To better cope with such a situation, we should have
- a reports module that tests if mime type detection works
- a heuristic that tries to guess the file type if no mime type can be extracted (we might as well have a fixed list of file extensions as was suggested in the comments for #46020)
Andreas Wolf wrote:
When no library is available for doing mime type detection, information like the dimensions of images is not indexed. This leads to several problems e.g. in the frontend output.
To better cope with such a situation, we should have
- a reports module that tests if mime type detection works
- a heuristic that tries to guess the file type if no mime type can be extracted (we might as well have a fixed list of file extensions as was suggested in the comments for #46020)
- A Hook (or signal) for the mime type detection, as it might be useful to set mime types for "own" file suffixes.
- Sprint Focus set to On Location Sprint
A signal should be added to LocalDriver::getMimeTypeOfFile()
Something like:
/**
* Get MIME type of file.
*
* @param string $absoluteFilePath Absolute path to file
* @return string|boolean MIME type. eg, text/html, FALSE on error
*/
protected function getMimeTypeOfFile($absoluteFilePath) {
$mimeType = FALSE;
if (function_exists('finfo_file')) {
$fileInfo = new \finfo();
$mimeType = $fileInfo->file($absoluteFilePath, FILEINFO_MIME_TYPE);
} elseif (function_exists('mime_content_type')) {
$mimeType = mime_content_type($absoluteFilePath);
}
$this->emitGetMimeTypeOfFileSignal($absoluteFilePath, $mimeType);
return $mimeType;
}
/**
* @param $absoluteFilePath
* @param $mimeType
*/
protected function emitGetMimeTypeOfFileSignal($absoluteFilePath, &$mimeType) {
$this->signalSlotDispatcher->dispatch(self::class, self::SIGNAL_GetMimeTypeOfFile, array($this, $absoluteFilePath, $mimeType));
}
- Status changed from Accepted to New
- Status changed from New to In Progress
- Status changed from In Progress to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/36358
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/36358
- Status changed from Under Review to Closed
- Sprint Focus deleted (
On Location Sprint)
Also available in: Atom
PDF