mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
inline image extractor (to add attachments for all inline images) was also extracting images from code blocks.
This commit is contained in:
parent
dec3021ab8
commit
4c935b94cd
1 changed files with 11 additions and 1 deletions
|
@ -1152,10 +1152,20 @@ class Activity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$images = false;
|
||||
|
||||
// protect code blocks before searching for images
|
||||
$item['body'] = preg_replace_callback('#(^|\n)([`~]{3,})(?: *\.?([a-zA-Z0-9\-.]+))?\n+([\s\S]+?)\n+\2(\n|$)#', function ($match) {
|
||||
return $match[1] . $match[2] . "\n" . bb_code_protect($match[4]) . "\n" . $match[2] . (($match[5]) ?: "\n");
|
||||
}, $item['body']);
|
||||
$item['body'] = preg_replace_callback('/\[code(.*?)\[\/(code)\]/ism', '\red_escape_codeblock', $item['body']);
|
||||
// find all inline images (outside protected code blocks) to add back as attachments
|
||||
$has_images = preg_match_all('/\[[zi]mg(.*?)](.*?)\[/ism', $item['body'], $images, PREG_SET_ORDER);
|
||||
|
||||
$item['body'] = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism', '\red_unescape_codeblock', $item['body']);
|
||||
$item['body'] = bb_code_unprotect($item['body']);
|
||||
|
||||
|
||||
$activity['id'] = $item['mid'];
|
||||
|
||||
$activity['published'] = datetime_convert('UTC', 'UTC', $item['created'], ATOM_TIME);
|
||||
|
|
Loading…
Reference in a new issue