mirror of
https://github.com/friendica/friendica
synced 2025-04-23 05:10:11 +00:00
AP: Remove the link description from the "rich html" and adds it to the attachment
This commit is contained in:
parent
19bbae21de
commit
28ca0d6fab
2 changed files with 51 additions and 1 deletions
|
@ -385,6 +385,28 @@ class BBCode extends BaseObject
|
|||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove [attachment] BBCode and replaces it with a regular [url]
|
||||
*
|
||||
* @param string $body
|
||||
*
|
||||
* @return string with replaced body
|
||||
*/
|
||||
public static function removeAttachment($body)
|
||||
{
|
||||
return preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism",
|
||||
function ($match) {
|
||||
$attach_data = self::getAttachmentData($match[0]);
|
||||
if (empty($attach_data['url'])) {
|
||||
return $match[0];
|
||||
} elseif (empty($attach_data['title'])) {
|
||||
return '[url]' . $attach_data['url'] . '[/url]';
|
||||
} else {
|
||||
return '[url=' . $attach_data['url'] . ']' . $attach_data['title'] . '[/url]';
|
||||
}
|
||||
}, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts a BBCode text into plaintext
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue