]> git.mxchange.org Git - friendica.git/commitdiff
Allow to upload pictures up to the allowed system upload size
authorMichael <heluecht@pirati.ca>
Fri, 17 Nov 2023 12:19:01 +0000 (12:19 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 17 Nov 2023 12:19:01 +0000 (12:19 +0000)
src/App/Page.php
src/Module/Settings/Display.php
src/Util/Images.php

index 08efac627fe287cf2f9cdf359a1abc12c3a2422e..71f75df15763666b8f98fabe7cba0ac22e805eac 100644 (file)
@@ -36,6 +36,7 @@ use Friendica\Core\System;
 use Friendica\Core\Theme;
 use Friendica\Module\Response;
 use Friendica\Network\HTTPException;
+use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\Profiler;
 use Friendica\Util\Strings;
@@ -282,7 +283,7 @@ class Page implements ArrayAccess
                        '$stylesheets'     => $this->stylesheets,
 
                        // Dropzone
-                       '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($config->get('system', 'maximagesize')) / 1000000, 1),
+                       '$max_imagesize' => round(Images::getMaxUploadBytes() / 1000000, 0),
 
                ]) . $this->page['htmlhead'];
        }
index 36eae53c277aca6380c059d11c171a23affde173..3cb5e44e2d7e1dfd2267b4e5b19cf74795271183 100644 (file)
@@ -95,7 +95,7 @@ class Display extends BaseSettings
                $user = User::getById($uid);
 
                $theme                  = trim($request['theme']);
-               $mobile_theme           = trim($request['mobile_theme']);
+               $mobile_theme           = trim($request['mobile_theme'] ?? '');
                $enable_smile           = (bool)$request['enable_smile'];
                $enable                 = (array)$request['enable'];
                $bookmark               = (array)$request['bookmark'];
index aed72f065b7c8c0810efa22c0aaa938ca6c7c46c..71a8bfea7e119e82056b10a078ea22785cf1c3e0 100644 (file)
@@ -244,22 +244,24 @@ class Images
                $filesize = strlen($img_str);
 
                try {
-                       $data = @getimagesizefromstring($img_str);
+                       $data = (array)@getimagesizefromstring($img_str);
                } catch (\Exception $e) {
                        return [];
                }
 
-               if ($data) {
-                       $image = new Image($img_str);
+               if (empty($data)) {
+                       return [];
+               }
 
-                       if ($image->isValid()) {
-                               $data['blurhash'] = $image->getBlurHash();
-                       }
+               $image = new Image($img_str);
 
-                       $data['size'] = $filesize;
+               if ($image->isValid()) {
+                       $data['blurhash'] = $image->getBlurHash();
                }
 
-               return is_array($data) ? $data : [];
+               $data['size'] = $filesize;
+
+               return $data;
        }
 
        /**
@@ -352,4 +354,15 @@ class Images
 
                return '[img=' . $photo . ']' . $description . '[/img]';
        }
+
+       /**
+        * Get the maximum possible upload size in bytes
+        *
+        * @return integer
+        */
+       public static function getMaxUploadBytes(): int
+       {
+               $upload_size = ini_get('upload_max_filesize') ?: DI::config()->get('system', 'maximagesize');
+               return Strings::getBytesFromShorthand($upload_size);
+       }
 }