Hook::register('photo_post_end', __FILE__, 'js_upload_post_end');
}
-function js_upload_form(App $a, array &$b)
+function js_upload_form(array &$b)
{
$b['default_upload'] = false;
'$cancel' => DI::l10n()->t('Cancel'),
'$failed' => DI::l10n()->t('Failed'),
'$post_url' => $b['post_url'],
- '$maximagesize' => intval(DI::config()->get('system', 'maximagesize')),
+ '$maximagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')),
]);
}
-function js_upload_post_init(App $a, &$b)
+function js_upload_post_init(array &$b)
{
global $js_upload_result, $js_upload_jsonresponse;
$allowedExtensions = ['jpeg', 'gif', 'png', 'jpg'];
// max file size in bytes
- $sizeLimit = DI::config()->get('system', 'maximagesize');
+ $sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$js_upload_result = $result;
}
-function js_upload_post_file(App $a, &$b)
+function js_upload_post_file(array &$b)
{
global $js_upload_result;
}
-function js_upload_post_end(App $a, &$b)
+function js_upload_post_end(int &$b)
{
global $js_upload_jsonresponse;
}
- private function toBytes($str)
- {
- $val = trim($str);
- $last = strtolower($str[strlen($str) - 1]);
- switch ($last) {
- case 'g':
- $val *= 1024;
- case 'm':
- $val *= 1024;
- case 'k':
- $val *= 1024;
- }
- return $val;
- }
-
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
// }
- $maximagesize = DI::config()->get('system', 'maximagesize');
+ $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
if (($maximagesize) && ($size > $maximagesize)) {
return ['error' => DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize))];