mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Ensure $attachment has a width and a height when it's an image in Mastodon\Attachment
- Address https://github.com/friendica/friendica/issues/11993#issuecomment-1323274513
This commit is contained in:
parent
a5af1408d6
commit
7c6d54c989
2 changed files with 16 additions and 6 deletions
|
@ -94,12 +94,17 @@ class Attachment extends BaseFactory
|
|||
*/
|
||||
public function createFromPhoto(int $id): array
|
||||
{
|
||||
$photo = Photo::selectFirst(['resource-id', 'uid', 'id', 'title', 'type'], ['id' => $id]);
|
||||
$photo = Photo::selectFirst(['resource-id', 'uid', 'id', 'title', 'type', 'width', 'height'], ['id' => $id]);
|
||||
if (empty($photo)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$attachment = ['id' => $photo['id'], 'description' => $photo['title']];
|
||||
$attachment = [
|
||||
'id' => $photo['id'],
|
||||
'description' => $photo['title'],
|
||||
'width' => $photo['width'],
|
||||
'height' => $photo['height'],
|
||||
];
|
||||
|
||||
$photoTypes = Images::supportedTypes();
|
||||
$ext = $photoTypes[$photo['type']];
|
||||
|
@ -113,7 +118,6 @@ class Attachment extends BaseFactory
|
|||
$preview_url = '';
|
||||
}
|
||||
|
||||
|
||||
$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, 'image', $url, $preview_url, '');
|
||||
return $object->toArray();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue