Support » Plugin: Image Teleporter » suggested fix

  • I believe the problem is that certain hosts don’t include the finfo function by default, even in PHP5.3… I was able to get around this by changing the function near line 136 to:

    function _mime_content_type($filename) {
    	if (function_exists("finfo_file")) {
    		$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
    		$mime = finfo_file($finfo, $absoluteFilePath);
    		finfo_close($finfo);
    		return $mime;
    	} else if (function_exists("mime_content_type")) {
    		return mime_content_type($absoluteFilePath);
    	} else if (!stristr(ini_get("disable_functions"), "shell_exec")) {
    	// http://stackoverflow.com/a/134930/1593459
    	$file = escapeshellarg($absoluteFilePath);
    	$mime = shell_exec("file -bi " . $absoluteFilePath);
    	return $mime;
    } else {
    	return false;
    }
    
    /*
    	// Instantiate finfo
    	$result = new finfo_open();
    	// Get Mime Type with PHP 5.3 compatible method
    	if (is_resource($result) === true) {
    		return $result->file($filename, FILEINFO_MIME_TYPE);
    	}
    
    	return false;
    */
    }

    http://wordpress.org/plugins/image-teleporter/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘suggested fix’ is closed to new replies.