]> git.mxchange.org Git - friendica-addons.git/commitdiff
Adjusted code use of shorthandnotation for image size upload limits
authorMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 30 Nov 2022 20:27:14 +0000 (21:27 +0100)
committerMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 30 Nov 2022 20:27:14 +0000 (21:27 +0100)
js_upload/js_upload.php

index 8d8af072df91d3a09511d1b1004002ec0da3d51c..0c8e58363774060bf758a291bad4954cb5d04ebe 100644 (file)
@@ -39,7 +39,7 @@ 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')),
        ]);
 }
 
@@ -51,7 +51,7 @@ function js_upload_post_init(App $a, array &$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);
 
@@ -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')
         */