aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-06-18 09:51:20 +0000
committerMario <mario@mariovavti.com>2021-06-18 09:51:20 +0000
commitc42d8a81c729ff8441195371106e96d398210067 (patch)
tree3380702c7290832ff785f740e8f7c4f2e4bc9205
parent0e7473c3ba4e1da24ee4b7c9cc32645364e31a3d (diff)
downloadvolse-hubzilla-c42d8a81c729ff8441195371106e96d398210067.tar.gz
volse-hubzilla-c42d8a81c729ff8441195371106e96d398210067.tar.bz2
volse-hubzilla-c42d8a81c729ff8441195371106e96d398210067.zip
bbcode: add option to drop media content
-rw-r--r--Zotlabs/Widget/Messages.php2
-rw-r--r--include/bbcode.php21
2 files changed, 22 insertions, 1 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index a03238c9a..95f3d4eb6 100644
--- a/Zotlabs/Widget/Messages.php
+++ b/Zotlabs/Widget/Messages.php
@@ -95,7 +95,7 @@ class Messages {
$summary = $item['summary'];
}
if (!$summary) {
- $summary = htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_QUOTES, 'UTF-8', false);
+ $summary = htmlentities(html2plain(bbcode($item['body'], ['drop_media' => true]), 75, true), ENT_QUOTES, 'UTF-8', false);
}
if (!$summary) {
$summary = '...';
diff --git a/include/bbcode.php b/include/bbcode.php
index a362e9ce9..87a7e6af6 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1099,6 +1099,27 @@ function bbcode($Text, $options = []) {
call_hooks('bbcode_filter', $Text);
+ if(isset($options['drop_media'])) {
+ if (strpos($Text,'[/img]') !== false) {
+ $Text = preg_replace('/\[img(.*?)\[\/(img)\]/ism', '', $Text);
+ }
+ if (strpos($Text,'[/audio]') !== false) {
+ $Text = preg_replace('/\[audio(.*?)\[\/(audio)\]/ism', '', $Text);
+ }
+ if (strpos($Text,'[/video]') !== false) {
+ $Text = preg_replace('/\[video(.*?)\[\/(video)\]/ism', '', $Text);
+ }
+ if (strpos($Text,'[/zmg]') !== false) {
+ $Text = preg_replace('/\[zmg(.*?)\[\/(zmg)\]/ism', '', $Text);
+ }
+ if (strpos($Text,'[/zaudio]') !== false) {
+ $Text = preg_replace('/\[zaudio(.*?)\[\/(zaudio)\]/ism', '', $Text);
+ }
+ if (strpos($Text,'[/zvideo]') !== false) {
+ $Text = preg_replace('/\[zvideo(.*?)\[\/(zvideo)\]/ism', '', $Text);
+ }
+ }
+
// Hide all [noparse] contained bbtags by spacefying them
if (strpos($Text,'[noparse]') !== false) {
$Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text);