From 76a7ad3161be0994d7ba98e9dff9b317b2430bb3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 10:07:32 -0700 Subject: Overhaul of the uploader code: - Propagate size limits (including detecting memory limits from GD) down to the Flash so that we don't even start uploads that won't work - Improve the error messages to be more user meaningful and provide links to the codex for errors - Tell the user up front what the file size limit is. Fixes #1638 --- modules/gallery/helpers/graphics.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/gallery/helpers/graphics.php') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 04501132..d19392cf 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -423,4 +423,23 @@ class graphics_Core { return true; } + + /** + * Return the max file size that this graphics toolkit can handle. + */ + static function max_filesize() { + if (module::get_var("gallery", "graphics_toolkit") == "gd") { + $memory_limit = trim(ini_get("memory_limit")); + $memory_limit_bytes = num::convert_to_bytes($memory_limit); + + // GD expands images in memory and uses 4 bytes of RAM for every byte + // in the file. + $max_filesize = $memory_limit_bytes / 4; + $max_filesize_human_readable = num::convert_to_human_readable($max_filesize); + return array($max_filesize, $max_filesize_human_readable); + } + + // Some arbitrarily large size + return array(1000000000, "1G"); + } } -- cgit v1.2.3