- switch ($attach['type']) {
- case 'link':
- $data = [
- 'url' => $attach['url'],
- 'type' => $attach['type'],
- 'title' => $attach['title'] ?? '',
- 'text' => $attach['desc'] ?? '',
- 'image' => $attach['image'] ?? '',
- 'images' => [],
- 'keywords' => [],
- ];
- $item['body'] = PageInfo::appendDataToBody($item['body'], $data);
- break;
- default:
- self::storeAttachmentAsMedia($item['uri-id'], $attach);
-
- $filetype = strtolower(substr($attach['mediaType'], 0, strpos($attach['mediaType'], '/')));
- if ($filetype == 'image') {
- if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
- 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'] .= '[img]' . $attach['url'] . '[/img]';
- } else {
- $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'])) {
- continue 2;
- }
-
- $item['body'] .= "\n[audio]" . $attach['url'] . '[/audio]';
- } elseif ($filetype == 'video') {
- if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
- continue 2;
- }
-
- $item['body'] .= "\n[video]" . $attach['url'] . '[/video]';
- }
- }