Task #46777
Improve behaviour when mime type detection is missing
Status: | Closed | Start date: | 2013-03-29 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | File Abstraction Layer (FAL) | Spent time: | - | |
Target version: | 6.1.0 | |||
TYPO3 Version: | 6.0 | Complexity: | easy | |
PHP Version: | Sprint Focus: | On Location Sprint |
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)
Related issues
Associated revisions
[FEATURE] Add SplFileInfo implementation to get file mimeType
\TYPO3\CMS\Core\Type\File\FileInfo provides a new method
getMimeType() to get the MIME type of a file, e.g. text/html.
Custom implementations to determine the MIME type can be added
with the hook:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']
The FAL LocalDriver also uses this new API.
Resolves: #60019
References: #46777
Releases: master
Change-Id: Ia2fa95d2ef6452f8022e33f1b1d2a9336f3e0303
Reviewed-on: http://review.typo3.org/31256
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Steffen Müller <typo3@t3node.com>
Reviewed-by: Steffen Müller <typo3@t3node.com>
History
#1 Updated by Helmut Hummel over 2 years ago
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.
#2 Updated by Mathias Schreiber 7 months ago
- Sprint Focus set to On Location Sprint
#3 Updated by Frans Saris 6 months ago
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)); }
#4 Updated by Mathias Schreiber 6 months ago
- Status changed from Accepted to New
#5 Updated by Frans Saris 6 months ago
- Status changed from New to In Progress
#6 Updated by Gerrit Code Review 6 months ago
- 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
#7 Updated by Gerrit Code Review 6 months ago
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
#8 Updated by Mathias Schreiber 6 months ago
- Status changed from Under Review to Closed