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