/** * This function returns aproximate maximum size for an image being uploaded if imageMagick is not available. * This function is meant to be used by the single and batch image uploaders to get a warning message to display * @return array An array containing the index 'res' holding a string representing dimensions (i.e. '1500px x 1500px') * and the index 'mps' holding a float representing the number of megapixels that this size is. */ function get_approx_max_image_size() { $ret = array(); $x = round(sqrt(0.79 * (get_php_size_setting_as_bytes('memory_limit') - memory_get_usage()) * 8 / (4 * 16))); $ret['res'] = $x . 'px x ' . $x . 'px'; $ret['mps'] = round($x * $x / 1000000, 1); return $ret; }
function get_actual_max_upload_size() { $sizes = array(); $post_max_size = get_php_size_setting_as_bytes('post_max_size'); $upload_max_filesize = get_php_size_setting_as_bytes('upload_max_filesize'); $reason_max_media_upload = MEDIA_MAX_UPLOAD_FILESIZE_MEGS * 1024 * 1024; if ($post_max_size < $reason_max_media_upload || $upload_max_filesize < $reason_max_media_upload) { if ($post_max_size < $upload_max_filesize) { trigger_error('post_max_size in php.ini is less than Reason setting MEDIA_MAX_UPLOAD_FILESIZE_MEGS; using post_max_size as max upload value'); return $post_max_size; } else { trigger_error('upload_max_filesize in php.ini is less than Reason setting MEDIA_MAX_UPLOAD_FILESIZE_MEGS; using upload_max_filesize as max upload value'); return $upload_max_filesize; } } else { return $reason_max_media_upload; } }
function reason_get_asset_max_upload_size() { static $max; if (!empty($max)) { return $max; } $post_max_size = get_php_size_setting_as_bytes('post_max_size'); $upload_max_filesize = get_php_size_setting_as_bytes('upload_max_filesize'); if (!defined('REASON_ASSET_MAX_UPLOAD_SIZE_MEGS')) { return $post_max_size < $upload_max_filesize ? $post_max_size : $upload_max_filesize; } $reason_max_asset_upload = REASON_ASSET_MAX_UPLOAD_SIZE_MEGS * 1024 * 1024; if ($post_max_size < $reason_max_asset_upload || $upload_max_filesize < $reason_max_asset_upload) { if ($post_max_size < $upload_max_filesize) { trigger_error('post_max_size in php.ini is less than Reason setting REASON_ASSET_MAX_UPLOAD_SIZE_MEGS; using post_max_size as max upload value'); return $max = $post_max_size; } else { trigger_error('upload_max_filesize in php.ini is less than Reason setting REASON_ASSET_MAX_UPLOAD_SIZE_MEGS; using upload_max_filesize as max upload value'); return $max = $upload_max_filesize; } } else { return $max = $reason_max_asset_upload; } }