]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Images.php
Friendica copyright changed from 2023 to 2034
[friendica.git] / src / Util / Images.php
index 90c2aae9db987a59cf4de88262df3d97faea12b5..b44b1fb8f558fe0a4dbc76078dc531e4dc8a8155 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2023, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -249,17 +249,19 @@ class Images
                        return [];
                }
 
-               if ($data) {
-                       $image = new Image($img_str);
+               if (!$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;
        }
 
        /**
@@ -343,11 +345,24 @@ class Images
         * @param string $preview Preview image URL
         * @param string $description
         * @return string
-        */     public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
+        */
+       public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
        {
                if (!empty($preview)) {
                        return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
                }
+
                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);
+       }
 }