note 79688 added to function.image-type-to-extension
| From: | mew at world dot org | Date: | Sat, 08 Dec 2007 07:26:14 +0000 |
| Subject: | note 79688 added to function.image-type-to-extension | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132948@lists.php.net to get a copy of this message | ||
There is no need to over complicated folks.
<?php
if ( !function_exists('image_type_to_extension') ) {
function image_type_to_extension ($type, $dot = true)
{
$e = array ( 1 => 'gif', 'jpeg', 'png', 'swf',
'psd', 'bmp'
'tiff', 'tiff', 'jpc', 'jp2', 'jpf',
'jb2', 'swc',
'aiff', 'wbmp', 'xbm');
// We are expecting an integer.
$type = (int)$type;
if (!$type) {
trigger_error( '...come up with an error here...', E_USER_NOTICE );
return null;
}
if ( !isset($e[$type]) ) {
trigger_error( '...come up with an error here...' E_USER_NOTICE );
return null;
}
return ($dot ? '.' : '') . $e[$type];
}
}
if ( !function_exists('image_type_to_mime_type') ) {
function image_type_to_mime_type ($type)
{
$m = array ( 1 => 'image/gif', 'image/jpeg', 'image/png',
'application/x-shockwave-flash', 'image/psd', 'image/bmp',
'image/tiff', 'image/tiff', 'application/octet-stream',
'image/jp2', 'application/octet-stream',
'application/octet-stream',
'application/x-shockwave-flash', 'image/iff', 'image/vnd.wap.wbmp',
'image/xbm');
// We are expecting an integer.
$type = (int)$type;
if (!$type) {
trigger_error( '...come up with an error here...', E_USER_NOTICE );
return null;
}
if ( !isset($m[$type]) ) {
trigger_error( '...come up with an error here...' E_USER_NOTICE );
return null;
}
return $m[$type];
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.171.101.17
----
Manual Page -- http://www.php.net/manual/en/function.image-type-to-extension.php
Edit -- https://master.php.net/note/edit/79688
Del: integrated -- https://master.php.net/note/delete/79688/integrated
Del: useless -- https://master.php.net/note/delete/79688/useless
Del: bad code -- https://master.php.net/note/delete/79688/bad+code
Del: spam -- https://master.php.net/note/delete/79688/spam
Del: non-english -- https://master.php.net/note/delete/79688/non-english
Del: in docs -- https://master.php.net/note/delete/79688/in+docs
Del: other reasons-- https://master.php.net/note/delete/79688
Reject -- https://master.php.net/note/reject/79688
Search -- https://master.php.net/manage/user-notes.php