Improved handling of leading and trailing attachments
This commit is contained in:
parent
6c4ddbdcd8
commit
274130f2eb
1 changed files with 21 additions and 8 deletions
|
@ -162,6 +162,9 @@ class Processor
|
|||
return $item;
|
||||
}
|
||||
|
||||
$leading = '';
|
||||
$trailing = '';
|
||||
|
||||
foreach ($activity['attachments'] as $attach) {
|
||||
switch ($attach['type']) {
|
||||
case 'link':
|
||||
|
@ -193,39 +196,49 @@ class Processor
|
|||
}
|
||||
}
|
||||
|
||||
$item['body'] .= "\n";
|
||||
|
||||
// image is the preview/thumbnail URL
|
||||
if (!empty($attach['image'])) {
|
||||
$item['body'] .= '[url=' . $attach['url'] . ']';
|
||||
$trailing .= '[url=' . $attach['url'] . ']';
|
||||
$attach['url'] = $attach['image'];
|
||||
}
|
||||
|
||||
if (empty($attach['name'])) {
|
||||
$item['body'] .= '[img]' . $attach['url'] . '[/img]';
|
||||
$trailing .= '[img]' . $attach['url'] . '[/img]';
|
||||
} else {
|
||||
$item['body'] .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
$trailing .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
}
|
||||
|
||||
if (!empty($attach['image'])) {
|
||||
$item['body'] .= '[/url]';
|
||||
$trailing .= '[/url]';
|
||||
}
|
||||
} elseif ($filetype == 'audio') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$item['body'] = '[audio]' . $attach['url'] . "[/audio]\n" . $item['body'];
|
||||
$leading .= '[audio]' . $attach['url'] . "[/audio]\n";
|
||||
} elseif ($filetype == 'video') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$item['body'] = '[video]' . $attach['url'] . "[/video]\n" . $item['body'];
|
||||
$leading .= '[video]' . $attach['url'] . "[/video]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($leading) && !empty(trim($item['body']))) {
|
||||
$item['body'] = $leading . "[hr]\n" . $item['body'];
|
||||
} elseif (!empty($leading)) {
|
||||
$item['body'] = $leading;
|
||||
}
|
||||
|
||||
if (!empty($trailing) && !empty(trim($item['body']))) {
|
||||
$item['body'] = $item['body'] . "\n[hr]" . $trailing;
|
||||
} elseif (!empty($trailing)) {
|
||||
$item['body'] = $trailing;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue