| @@ 2001-2011 (lines=11) @@ | ||
| 1998 | * @return bool | |
| 1999 | */ | |
| 2000 | 	protected function is_file_supported_for_sideloading( $file ) { | |
| 2001 | 		if ( class_exists( 'finfo' ) ) { // php 5.3+ | |
| 2002 | $finfo = new finfo( FILEINFO_MIME ); | |
| 2003 | $mime = explode( '; ', $finfo->file( $file ) ); | |
| 2004 | $type = $mime[0]; | |
| 2005 | ||
| 2006 | 		} elseif ( function_exists( 'mime_content_type' ) ) { // PHP 5.2 | |
| 2007 | $type = mime_content_type( $file ); | |
| 2008 | ||
| 2009 | 		} else { | |
| 2010 | return false; | |
| 2011 | } | |
| 2012 | ||
| 2013 | /** | |
| 2014 | * Filter the list of supported mime types for media sideloading. | |
| @@ 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))); | |