- $siteinfo = BBCode::getAttachedData($item['body']);
-
- switch ($siteinfo['type']) {
- case 'photo':
- if (!empty($siteinfo['image'])) {
- $imgdata = Images::getInfoFromURLCached($siteinfo['image']);
- if ($imgdata) {
- $attributes = [
- 'rel' => 'enclosure',
- 'href' => $siteinfo['image'],
- 'type' => $imgdata['mime'],
- 'length' => intval($imgdata['size']),
- ];
- XML::addElement($doc, $root, 'link', '', $attributes);
- }
- }
- break;
-
- case 'video':
- $attributes = [
- 'rel' => 'enclosure',
- 'href' => $siteinfo['url'],
- 'type' => 'text/html; charset=UTF-8',
- 'length' => '0',
- 'title' => ($siteinfo['title'] ?? '') ?: $siteinfo['url'],
- ];
- XML::addElement($doc, $root, 'link', '', $attributes);
- break;
- }
-
- if (!DI::config()->get('system', 'ostatus_not_attach_preview') && ($siteinfo['type'] != 'photo') && isset($siteinfo['image'])) {
- $imgdata = Images::getInfoFromURLCached($siteinfo['image']);
- if ($imgdata) {
- $attributes = [
- 'rel' => 'enclosure',
- 'href' => $siteinfo['image'],
- 'type' => $imgdata['mime'],
- 'length' => intval($imgdata['size']),
- ];
-
- XML::addElement($doc, $root, 'link', '', $attributes);
- }
- }
-
- foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT]) as $attachment) {