]> git.mxchange.org Git - friendica.git/commitdiff
Add support for image preview in attachments in ActivityPub\Processor
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 20 Jul 2020 04:27:36 +0000 (00:27 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 20 Jul 2020 04:28:11 +0000 (00:28 -0400)
- Address https://github.com/friendica/friendica/issues/8676#issuecomment-650554955

src/Protocol/ActivityPub/Processor.php

index e4cef17045a81378fac75ef7b1176236721afe30..177813e32d55067988372da2a890db1feabbd2df 100644 (file)
@@ -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'])) {