| @@ 1001-1009 (lines=9) @@ | ||
| 998 | if($fullpath && ($fsize = filesize($fullpath)) !== false) { |
|
| 999 | // IE8 can't handle data uris larger than 32KB |
|
| 1000 | if($fsize/1024 < 32) { |
|
| 1001 | if(is_null($mime)) { |
|
| 1002 | if(class_exists('finfo')) { // php 5.3+ |
|
| 1003 | $finfo = new finfo(FILEINFO_MIME); |
|
| 1004 | $mime = explode('; ', $finfo->file($fullpath)); |
|
| 1005 | $mime = $mime[0]; |
|
| 1006 | } elseif(function_exists('mime_content_type')) { // PHP 5.2 |
|
| 1007 | $mime = mime_content_type($fullpath); |
|
| 1008 | } |
|
| 1009 | } |
|
| 1010 | ||
| 1011 | if(!is_null($mime)) // fallback if the mime type is still unknown |
|
| 1012 | $url = sprintf('data:%s;base64,%s', $mime, base64_encode(file_get_contents($fullpath))); |
|
| @@ 1739-1749 (lines=11) @@ | ||
| 1736 | * @return bool |
|
| 1737 | */ |
|
| 1738 | protected function is_file_supported_for_sideloading( $file ) { |
|
| 1739 | if ( class_exists( 'finfo' ) ) { // php 5.3+ |
|
| 1740 | $finfo = new finfo( FILEINFO_MIME ); |
|
| 1741 | $mime = explode( '; ', $finfo->file( $file ) ); |
|
| 1742 | $type = $mime[0]; |
|
| 1743 | ||
| 1744 | } elseif ( function_exists( 'mime_content_type' ) ) { // PHP 5.2 |
|
| 1745 | $type = mime_content_type( $file ); |
|
| 1746 | ||
| 1747 | } else { |
|
| 1748 | return false; |
|
| 1749 | } |
|
| 1750 | ||
| 1751 | /** |
|
| 1752 | * Filter the list of supported mime types for media sideloading. |
|