mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 15:22:15 +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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue