@@ 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))); |
@@ 1778-1788 (lines=11) @@ | ||
1775 | * @return bool |
|
1776 | */ |
|
1777 | protected function is_file_supported_for_sideloading( $file ) { |
|
1778 | if ( class_exists( 'finfo' ) ) { // php 5.3+ |
|
1779 | $finfo = new finfo( FILEINFO_MIME ); |
|
1780 | $mime = explode( '; ', $finfo->file( $file ) ); |
|
1781 | $type = $mime[0]; |
|
1782 | ||
1783 | } elseif ( function_exists( 'mime_content_type' ) ) { // PHP 5.2 |
|
1784 | $type = mime_content_type( $file ); |
|
1785 | ||
1786 | } else { |
|
1787 | return false; |
|
1788 | } |
|
1789 | ||
1790 | /** |
|
1791 | * Filter the list of supported mime types for media sideloading. |