]> git.mxchange.org Git - friendica.git/commitdiff
Fix jpeg ending
authorMichael <heluecht@pirati.ca>
Sun, 9 Jan 2022 16:06:00 +0000 (16:06 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 9 Jan 2022 16:06:00 +0000 (16:06 +0000)
include/api.php
src/Model/User.php
src/Util/Images.php

index 7914b4dbd612fee42f4e31d74acf43a577217e0a..cf29a75e66eeae92b360ecc7eccc8d7331f5e8e6 100644 (file)
@@ -177,14 +177,14 @@ function prepare_photo_data($type, $scale, $photo_id, $uid)
                        for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
                                $data['photo']['links'][$k . ":link"]["@attributes"] = ["type" => $data['photo']['type'],
                                                                                "scale" => $k,
-                                                                               "href" => DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . Images::getExtensionByMimeType($data['photo']['type'])];
+                                                                               "href" => DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . Images::getExtensionByMimeType($data['photo']['type'])];
                        }
                } else {
                        $data['photo']['link'] = [];
                        // when we have profile images we could have only scales from 4 to 6, but index of array always needs to start with 0
                        $i = 0;
                        for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
-                               $data['photo']['link'][$i] = DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . Images::getExtensionByMimeType($data['photo']['type']);
+                               $data['photo']['link'][$i] = DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . Images::getExtensionByMimeType($data['photo']['type']);
                                $i++;
                        }
                }
@@ -335,7 +335,7 @@ function api_fr_photos_list($type)
                        $photo['album'] = $rr['album'];
                        $photo['filename'] = $rr['filename'];
                        $photo['type'] = $rr['type'];
-                       $thumb = DI::baseUrl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . "." . Images::getExtensionByMimeType($rr['type']);
+                       $thumb = DI::baseUrl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . Images::getExtensionByMimeType($rr['type']);
                        $photo['created'] = $rr['created'];
                        $photo['edited'] = $rr['edited'];
                        $photo['desc'] = $rr['desc'];
index d99588e05bb74246e779805291debec4c28b0140..93538bce641d684ba3601767fdffcc1a67f7288d 100644 (file)
@@ -850,19 +850,16 @@ class User
                                break;
                }
 
-               $updated =  '';
-               $imagetype = IMAGETYPE_JPEG;
+               $updated  =  '';
+               $mimetype = '';
 
                $photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => $scale, 'uid' => $user['uid'], 'profile' => true]);
                if (!empty($photo)) {
-                       $updated = max($photo['created'], $photo['edited'], $photo['updated']);
-
-                       if (in_array($photo['type'], ['image/png', 'image/gif'])) {
-                               $imagetype = IMAGETYPE_PNG;
-                       }
+                       $updated  = max($photo['created'], $photo['edited'], $photo['updated']);
+                       $mimetype = $photo['type'];
                }
 
-               return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
+               return $url . $user['nickname'] . Images::getExtensionByMimeType($mimetype) . ($updated ? '?ts=' . strtotime($updated) : '');
        }
 
        /**
@@ -880,22 +877,19 @@ class User
 
                $url = DI::baseUrl() . '/photo/banner/';
 
-               $updated  '';
-               $imagetype = IMAGETYPE_JPEG;
+               $updated  = '';
+               $mimetype = '';
 
                $photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => 3, 'uid' => $user['uid'], 'photo-type' => Photo::USER_BANNER]);
                if (!empty($photo)) {
-                       $updated = max($photo['created'], $photo['edited'], $photo['updated']);
-
-                       if (in_array($photo['type'], ['image/png', 'image/gif'])) {
-                               $imagetype = IMAGETYPE_PNG;
-                       }
+                       $updated  = max($photo['created'], $photo['edited'], $photo['updated']);
+                       $mimetype = $photo['type'];
                } else {
                        // Only for the RC phase: Don't return an image link for the default picture
                        return '';
                }
 
-               return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
+               return $url . $user['nickname'] . Images::getExtensionByMimeType($mimetype) . ($updated ? '?ts=' . strtotime($updated) : '');
        }
 
        /**
index 997f3c6f9dee66ea74223a282f8c6367a9a055f4..077509d3cb5e6e1c64105e2a7886bd131cf31be5 100644 (file)
@@ -63,7 +63,7 @@ class Images
                                break;
 
                        default:
-                               $imagetype = IMAGETYPE_JPC;
+                               $imagetype = IMAGETYPE_JPEG;
                                break;
                }