[ticket/10944] Reverted changes in PHPBB3-10963

is_image now just checks the mimetype reported by the browser
and get_mimetype goes back to being unused.

PHPBB3-10944
This commit is contained in:
Fyorl 2012-07-17 17:36:09 +01:00
parent b45bc27339
commit 6aea4db6c7

View file

@ -151,8 +151,7 @@ class filespec
*/ */
function is_image() function is_image()
{ {
$mimetype = $this->get_mimetype($this->filename); return (strpos($this->mimetype, 'image/') !== false) ? true : false;
return (strpos($mimetype, 'image/') === 0);
} }
/** /**
@ -201,12 +200,17 @@ class filespec
} }
/** /**
* Get mimetype. Utilises the finfo class. * Get mimetype. Utilize mime_content_type if the function exist.
* Not used at the moment...
*/ */
function get_mimetype($filename) function get_mimetype($filename)
{ {
$finfo = new finfo(FILEINFO_MIME_TYPE); $mimetype = '';
$mimetype = $finfo->file($filename);
if (function_exists('mime_content_type'))
{
$mimetype = mime_content_type($filename);
}
// Some browsers choke on a mimetype of application/octet-stream // Some browsers choke on a mimetype of application/octet-stream
if (!$mimetype || $mimetype == 'application/octet-stream') if (!$mimetype || $mimetype == 'application/octet-stream')
@ -338,7 +342,6 @@ class filespec
// Remove temporary filename // Remove temporary filename
@unlink($this->filename); @unlink($this->filename);
$this->filename = $this->destination_file;
if (sizeof($this->error)) if (sizeof($this->error))
{ {