Merge remote-tracking branch 'Fyorl/ticket/10963' into develop

* Fyorl/ticket/10963:
  [ticket/10963] filespec::get_mimetype now used
  [ticket/10963] Removed superfluous ternary statement and strpos now stricter
  [ticket/10963] Modified filespec::is_image() to check actual mimetype
This commit is contained in:
Andreas Fischer 2012-07-05 02:00:31 +02:00
commit c54d74ec0e

View file

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