]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Images.php
Merge pull request #11966 from annando/date-correction
[friendica.git] / src / Util / Images.php
index 595640698780e9deafa23507d742db464437a0bd..eb1e8c4375a491ca9f2ca7107082e52194cd5199 100644 (file)
@@ -140,14 +140,14 @@ class Images
         */
        public static function getMimeTypeBySource(string $sourcefile, string $filename = '', string $default = ''): string
        {
-               if (substr($mime, 0, 6) == 'image/') {
-                       Logger::info('Using default mime type', ['filename' => $filename, 'mime' => $mime]);
-                       return $mime;
+               if (substr($default, 0, 6) == 'image/') {
+                       Logger::info('Using default mime type', ['filename' => $filename, 'mime' => $default]);
+                       return $default;
                }
 
                $image = @getimagesize($sourcefile);
                if (!empty($image['mime'])) {
-                       Logger::info('Mime type detected via file', ['filename' => $filename, 'default' => $mime, 'image' => $image]);
+                       Logger::info('Mime type detected via file', ['filename' => $filename, 'default' => $default, 'image' => $image]);
                        return $image['mime'];
                }
 
@@ -179,7 +179,7 @@ class Images
        /**
         * Gets info array from given URL, cached data has priority
         *
-        * @param string $url URL
+        * @param string $url
         * @return array Info
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
@@ -201,12 +201,13 @@ class Images
                        DI::cache()->set($cacheKey, $data);
                }
 
-               return $data;
+               return $data ?? [];
        }
 
        /**
         * Gets info from URL uncached
-        * @param string $url URL
+        *
+        * @param string $url
         * @return array Info array
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
@@ -246,7 +247,7 @@ class Images
                        $data['size'] = $filesize;
                }
 
-               return $data;
+               return is_array($data) ? $data : [];
        }
 
        /**