| @@ 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))); |
|
| @@ 1766-1776 (lines=11) @@ | ||
| 1763 | * @return bool |
|
| 1764 | */ |
|
| 1765 | protected function is_file_supported_for_sideloading( $file ) { |
|
| 1766 | if ( class_exists( 'finfo' ) ) { // php 5.3+ |
|
| 1767 | $finfo = new finfo( FILEINFO_MIME ); |
|
| 1768 | $mime = explode( '; ', $finfo->file( $file ) ); |
|
| 1769 | $type = $mime[0]; |
|
| 1770 | ||
| 1771 | } elseif ( function_exists( 'mime_content_type' ) ) { // PHP 5.2 |
|
| 1772 | $type = mime_content_type( $file ); |
|
| 1773 | ||
| 1774 | } else { |
|
| 1775 | return false; |
|
| 1776 | } |
|
| 1777 | ||
| 1778 | /** |
|
| 1779 | * Filter the list of supported mime types for media sideloading. |
|