Project

General

Profile

Actions

Task #46777

closed

Improve behaviour when mime type detection is missing

Added by Andreas Wolf about 11 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2013-03-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.0
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

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

  1. a reports module that tests if mime type detection works
  2. 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 2 (0 open2 closed)

Related to TYPO3 Core - Bug #46020: Image size is 0 when not scaledClosedAlexander Opitz2013-03-04

Actions
Is duplicate of TYPO3 Core - Feature #60019: Create utility function to get the file mimetype depending on available php modulesClosed2014-07-01

Actions
Actions #1

Updated by Helmut Hummel about 11 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

  1. a reports module that tests if mime type detection works
  2. 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)
  1. A Hook (or signal) for the mime type detection, as it might be useful to set mime types for "own" file suffixes.
Actions #2

Updated by Mathias Schreiber over 9 years ago

  • Sprint Focus set to On Location Sprint
Actions #3

Updated by Frans Saris about 9 years 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));
    }

Actions #4

Updated by Mathias Schreiber about 9 years ago

  • Status changed from Accepted to New
Actions #5

Updated by Frans Saris about 9 years ago

  • Status changed from New to In Progress
Actions #6

Updated by Gerrit Code Review about 9 years 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

Actions #7

Updated by Gerrit Code Review about 9 years 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

Actions #8

Updated by Mathias Schreiber about 9 years ago

  • Status changed from Under Review to Closed
Actions #9

Updated by Anja Leichsenring over 8 years ago

  • Sprint Focus deleted (On Location Sprint)
Actions

Also available in: Atom PDF