mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Storage::getContentType() 메소드를 MIME 클래스로 이동함
This commit is contained in:
parent
9163bc24e9
commit
805a7324cc
4 changed files with 36 additions and 36 deletions
|
|
@ -15,7 +15,7 @@ class Image
|
|||
*/
|
||||
public static function isImage($filename)
|
||||
{
|
||||
return array_shift(explode('/', Storage::getContentType($filename))) === 'image';
|
||||
return array_shift(explode('/', MIME::getContentType($filename))) === 'image';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,7 +26,7 @@ class Image
|
|||
*/
|
||||
public static function isAnimatedGIF($filename)
|
||||
{
|
||||
if (Storage::getContentType($filename) !== 'image/gif')
|
||||
if (MIME::getContentType($filename) !== 'image/gif')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,38 @@ namespace Rhymix\Framework;
|
|||
*/
|
||||
class MIME
|
||||
{
|
||||
/**
|
||||
* Get the MIME type of a file, detected by its content.
|
||||
*
|
||||
* This method returns the MIME type of a file, or false on error.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getContentType($filename)
|
||||
{
|
||||
$filename = rtrim($filename, '/\\');
|
||||
if (Storage::exists($filename) && @is_file($filename) && @is_readable($filename))
|
||||
{
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
return @mime_content_type($filename) ?: false;
|
||||
}
|
||||
elseif (($image = @getimagesize($filename)) && $image['mime'])
|
||||
{
|
||||
return $image['mime'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return self::getTypeByFilename($filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MIME type for the given extension.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -143,38 +143,6 @@ class Storage
|
|||
return @self::exists($path) && @is_writable($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MIME content type of a file.
|
||||
*
|
||||
* This method returns the MIME content type of a file, or false on error.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getContentType($filename)
|
||||
{
|
||||
$filename = rtrim($filename, '/\\');
|
||||
if (self::exists($filename) && @is_file($filename) && @is_readable($filename))
|
||||
{
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
return @mime_content_type($filename) ?: false;
|
||||
}
|
||||
elseif (($image = @getimagesize($filename)) && $image['mime'])
|
||||
{
|
||||
return $image['mime'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return MIME::getTypeByFilename($filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a file.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ class fileController extends file
|
|||
|
||||
// Set base information
|
||||
$file_info['name'] = Rhymix\Framework\Filters\FilenameFilter::clean($file_info['name']);
|
||||
$file_info['type'] = $file_info['original_type'] = Rhymix\Framework\Storage::getContentType($file_info['tmp_name']);
|
||||
$file_info['type'] = $file_info['original_type'] = Rhymix\Framework\MIME::getContentType($file_info['tmp_name']);
|
||||
$file_info['extension'] = $file_info['original_extension'] = strtolower(array_pop(explode('.', $file_info['name'])));
|
||||
$file_info['width'] = null;
|
||||
$file_info['height'] = null;
|
||||
|
|
@ -1250,7 +1250,7 @@ class fileController extends file
|
|||
{
|
||||
$file_info['tmp_name'] = $output_name;
|
||||
$file_info['size'] = filesize($output_name);
|
||||
$file_info['type'] = Rhymix\Framework\Storage::getContentType($output_name);
|
||||
$file_info['type'] = Rhymix\Framework\MIME::getContentType($output_name);
|
||||
$file_info['extension'] = $adjusted['type'];
|
||||
$file_info['width'] = $adjusted['width'];
|
||||
$file_info['height'] = $adjusted['height'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue