mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 00:33:40 +00:00
[twitter] Add support for multiple images in parse_url hook function
This commit is contained in:
parent
0dce0b722b
commit
4d49833f8b
1 changed files with 10 additions and 7 deletions
|
@ -934,12 +934,15 @@ function twitter_parse_link(App $a, array &$b)
|
||||||
$item = twitter_createpost($a, 0, $status, [], true, false, true);
|
$item = twitter_createpost($a, 0, $status, [], true, false, true);
|
||||||
|
|
||||||
if ($b['format'] == 'json') {
|
if ($b['format'] == 'json') {
|
||||||
if (!empty($status->extended_entities->media[0]->media_url_https)) {
|
$images = [];
|
||||||
$images = [[
|
foreach ($status->extended_entities->media ?? [] as $media) {
|
||||||
'src' => $status->extended_entities->media[0]->media_url_https,
|
if (!empty($media->media_url_https)) {
|
||||||
'width' => $status->extended_entities->media[0]->sizes->thumb->w,
|
$images[] = [
|
||||||
'height' => $status->extended_entities->media[0]->sizes->thumb->h,
|
'src' => $media->media_url_https,
|
||||||
]];
|
'width' => $media->sizes->thumb->w,
|
||||||
|
'height' => $media->sizes->thumb->h,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$b['text'] = [
|
$b['text'] = [
|
||||||
|
@ -948,7 +951,7 @@ function twitter_parse_link(App $a, array &$b)
|
||||||
'url' => $item['plink'],
|
'url' => $item['plink'],
|
||||||
'title' => DI::l10n()->t('%s on Twitter', $status->user->name),
|
'title' => DI::l10n()->t('%s on Twitter', $status->user->name),
|
||||||
'text' => BBCode::toPlaintext($item['body'], false),
|
'text' => BBCode::toPlaintext($item['body'], false),
|
||||||
'images' => $images ?? [],
|
'images' => $images,
|
||||||
],
|
],
|
||||||
'contentType' => 'attachment',
|
'contentType' => 'attachment',
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
|
Loading…
Reference in a new issue