Partially revert changes for the RC
This commit is contained in:
parent
10bdaa0cfe
commit
bb349a7db4
5 changed files with 33 additions and 28 deletions
|
@ -34,6 +34,7 @@ use Friendica\Model\Photo;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Images;
|
||||
|
||||
$API = [];
|
||||
|
||||
|
@ -162,12 +163,6 @@ function prepare_photo_data($type, $scale, $photo_id, $uid)
|
|||
$photo_id
|
||||
));
|
||||
|
||||
$typetoext = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif'
|
||||
];
|
||||
|
||||
// prepare output data for photo
|
||||
if (DBA::isResult($r)) {
|
||||
$data = ['photo' => $r[0]];
|
||||
|
@ -182,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 . "." . $typetoext[$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 . "." . $typetoext[$data['photo']['type']];
|
||||
$data['photo']['link'][$i] = DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . Images::getExtensionByMimeType($data['photo']['type']);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
@ -331,11 +326,7 @@ function api_fr_photos_list($type)
|
|||
WHERE `uid` = ? AND NOT `photo-type` IN (?, ?) GROUP BY `resource-id`, `album`, `filename`, `type`",
|
||||
$uid, Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER
|
||||
));
|
||||
$typetoext = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif'
|
||||
];
|
||||
|
||||
$data = ['photo'=>[]];
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $rr) {
|
||||
|
@ -344,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'] . "." . $typetoext[$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'];
|
||||
|
|
|
@ -890,6 +890,9 @@ class User
|
|||
if (in_array($photo['type'], ['image/png', 'image/gif'])) {
|
||||
$imagetype = IMAGETYPE_PNG;
|
||||
}
|
||||
} 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) : '');
|
||||
|
|
|
@ -46,6 +46,30 @@ class Images
|
|||
return $m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return file extension for mime type
|
||||
* @param string $mimetype
|
||||
* @return string
|
||||
*/
|
||||
public static function getExtensionByMimeType(string $mimetype): string
|
||||
{
|
||||
switch ($mimetype) {
|
||||
case 'image/png':
|
||||
$imagetype = IMAGETYPE_PNG;
|
||||
break;
|
||||
|
||||
case 'image/gif':
|
||||
$imagetype = IMAGETYPE_GIF;
|
||||
break;
|
||||
|
||||
default:
|
||||
$imagetype = IMAGETYPE_JPC;
|
||||
break;
|
||||
}
|
||||
|
||||
return image_type_to_extension($imagetype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns supported image mimetypes and corresponding file extensions
|
||||
*
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1449);
|
||||
define('DB_UPDATE_VERSION', 1448);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
13
update.php
13
update.php
|
@ -1087,16 +1087,3 @@ function update_1446()
|
|||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
function update_1449()
|
||||
{
|
||||
$users = DBA::select('user', ['uid']);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
if (Contact::updateSelfFromUserID($user['uid'])) {
|
||||
Profile::publishUpdate($user['uid']);
|
||||
}
|
||||
}
|
||||
DBA::close($users);
|
||||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue