From 4826ab45befb9eb1c664b5d8c8a0f03a7b750b8b Mon Sep 17 00:00:00 2001 From: andi Date: Fri, 15 Apr 2005 14:14:16 +0200 Subject: new parser: images, added flash support #154 darcs-hash:20050415121416-9977f-583ee34659f70017fec4f8b8a4de327c5b1631e4.gz --- inc/utils.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'inc/utils.php') 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 */ -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 -- cgit v1.2.3