From 3894976a2d7dd42784488d3ff3ddb7ff53c25bc1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 20 Jul 2020 00:27:36 -0400 Subject: [PATCH] Add support for image preview in attachments in ActivityPub\Processor - Address https://github.com/friendica/friendica/issues/8676#issuecomment-650554955 --- src/Protocol/ActivityPub/Processor.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index e4cef17045..177813e32d 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -115,10 +115,22 @@ class Processor continue 2; } + $item['body'] .= "\n"; + + // image is the preview/thumbnail URL + if (!empty($attach['image'])) { + $item['body'] .= '[url=' . $attach['url'] . ']'; + $attach['url'] = $attach['image']; + } + if (empty($attach['name'])) { - $item['body'] .= "\n[img]" . $attach['url'] . '[/img]'; + $item['body'] .= '[img]' . $attach['url'] . '[/img]'; } else { - $item['body'] .= "\n[img=" . $attach['url'] . ']' . $attach['name'] . '[/img]'; + $item['body'] .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]'; + } + + if (!empty($attach['image'])) { + $item['body'] .= '[/url]'; } } elseif ($filetype == 'audio') { if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {