diff options
Diffstat (limited to 'inc/utils.php')
-rw-r--r-- | inc/utils.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/inc/utils.php b/inc/utils.php index 6610c217a..114fa3024 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -9,21 +9,24 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); /** - * Returns the (known) extension of a given filename - * - * returns false if not a known extension + * Returns the (known) extension and mimetype of a given filename * * @author Andreas Gohr <andi@splitbrain.org> */ -function media_extension($file){ - $exts = join('|',array_keys(getMimeTypes())); +function mimetype($file){ + $ret = array(false,false); // return array + $mtypes = getMimeTypes(); // known mimetypes + $exts = join('|',array_keys($mtypes)); // known extensions (regexp) if(preg_match('#\.('.$exts.')$#i',$file,$matches)){ - return strtolower($matches[1]); + $ext = strtolower($matches[1]); } - - return false; -} + if($ext && $mtypes[$ext]){ + $ret = array($ext, $mtypes[$ext]); + } + + return $ret; +} /** * returns a hash of mimetypes |