Better fix for displaying max file size.

This commit is contained in:
Sean Murphy 2009-02-05 15:01:44 -05:00
parent 746a5d7507
commit d4bdb2dc19
4 changed files with 9 additions and 5 deletions

View File

@ -155,7 +155,7 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->element('input', array('name' => 'MAX_FILE_SIZE', $this->element('input', array('name' => 'MAX_FILE_SIZE',
'type' => 'hidden', 'type' => 'hidden',
'id' => 'MAX_FILE_SIZE', 'id' => 'MAX_FILE_SIZE',
'value' => MAX_AVATAR_SIZE)); 'value' => ImageFile::maxFileSize(true)));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');

View File

@ -229,7 +229,7 @@ class GrouplogoAction extends Action
$this->element('input', array('name' => 'MAX_FILE_SIZE', $this->element('input', array('name' => 'MAX_FILE_SIZE',
'type' => 'hidden', 'type' => 'hidden',
'id' => 'MAX_FILE_SIZE', 'id' => 'MAX_FILE_SIZE',
'value' => MAX_AVATAR_SIZE)); 'value' => ImageFile::maxFileSize(true)));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');

View File

@ -24,7 +24,6 @@ define('LACONICA_VERSION', '0.7.0');
define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48); define('AVATAR_STREAM_SIZE', 48);
define('AVATAR_MINI_SIZE', 24); define('AVATAR_MINI_SIZE', 24);
define('MAX_AVATAR_SIZE', 256 * 1024);
define('NOTICES_PER_PAGE', 20); define('NOTICES_PER_PAGE', 20);
define('PROFILES_PER_PAGE', 20); define('PROFILES_PER_PAGE', 20);

View File

@ -183,9 +183,14 @@ class ImageFile
@unlink($this->filename); @unlink($this->filename);
} }
static function maxFileSize() static function maxFileSize($return_bytes = false)
{ {
$limit = min(ImageFile::strToInt(ini_get('post_max_size')), ImageFile::strToInt(ini_get('upload_max_filesize'))); $limit = min(ImageFile::strToInt(ini_get('post_max_size')), ImageFile::strToInt(ini_get('upload_max_filesize')), ImageFile::strToInt(ini_get('memory_limit')));
if ($return_bytes) {
return $limit;
}
return ($limit/(1024*1024)).'MB'; return ($limit/(1024*1024)).'MB';
} }