$mem_avail) { return false; } return true; } /** * Check if image is within limits * * @param int $image_size * @return bool false = too large */ function tp_upload_check_max_size($image_size) { $max_file_size = (float) elgg_get_plugin_setting('maxfilesize', 'tidypics'); if (!$max_file_size) { // default to 5 MB if not set $max_file_size = 5; } // convert to bytes from MBs $max_file_size = 1024 * 1024 * $max_file_size; return $image_size <= $max_file_size; } /** * Check if this image pushes user over quota * * @param int $image_size * @param int $owner_guid * @return bool false = exceed quota */ function tp_upload_check_quota($image_size, $owner_guid) { static $quota; if (!isset($quota)) { $quota = elgg_get_plugin_setting('quota', 'tidypics'); $quota = 1024 * 1024 * $quota; } if ($quota == 0) { // no quota return true; } $owner = get_entity($owner_guid); $image_repo_size_md = (int)$owner->image_repo_size; return ($image_repo_size + $image_size) < $quota; }