About 0.74% of load.php is spent in CSSMin::getMimeType/finfo_file.
We don't apply this to user-generated content of external urls,
only local files in version control. And in terms of correctness,
we don't support misleading file names, so it's not a problem that
a foo.png containing XML/SVG content would get the wrong mime-type
when base64 embedding it in CSS.
Change-Id: I17686467c897984117671098e94db8732446dc75
* @return bool|string
*/
public static function getMimeType( $file ) {
+ // Infer the MIME-type from the file extension
+ $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
+ if ( isset( self::$mimeTypes[$ext] ) ) {
+ return self::$mimeTypes[$ext];
+ }
+
$realpath = realpath( $file );
if (
$realpath
return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath );
}
- // Infer the MIME-type from the file extension
- $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
- if ( isset( self::$mimeTypes[$ext] ) ) {
- return self::$mimeTypes[$ext];
- }
-
return false;
}