WordPress.org

Forums

Image Teleporter
suggested fix (2 posts)

  1. Aaron Sylvan
    Member
    Posted 1 year ago #

    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/

  2. Trisha Cupra
    Member
    Plugin Contributor

    Posted 1 year ago #

    Thanks Aaron.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Image Teleporter
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags