]> git.mxchange.org Git - friendica-addons.git/blobdiff - js_upload/js_upload.php
Coloured box added
[friendica-addons.git] / js_upload / js_upload.php
index 72653d5573c4b16f75bd9790e4e428f612fb7b01..089cb7e214802739e5a921487bda2726adee421f 100644 (file)
@@ -25,7 +25,7 @@ function js_upload_install()
        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;
 
@@ -39,11 +39,11 @@ function js_upload_form(App $a, array &$b)
                '$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;
 
@@ -51,7 +51,7 @@ function js_upload_post_init(App $a, &$b)
        $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);
 
@@ -69,7 +69,7 @@ function js_upload_post_init(App $a, &$b)
        $js_upload_result = $result;
 }
 
-function js_upload_post_file(App $a, &$b)
+function js_upload_post_file(array &$b)
 {
        global $js_upload_result;
 
@@ -81,7 +81,7 @@ function js_upload_post_file(App $a, &$b)
 
 }
 
-function js_upload_post_end(App $a, &$b)
+function js_upload_post_end(int &$b)
 {
        global $js_upload_jsonresponse;
 
@@ -200,21 +200,6 @@ class qqFileUploader
 
        }
 
-       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')
         */
@@ -236,7 +221,7 @@ class qqFileUploader
 //             }
 
 
-               $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))];