From 2769089120cb6247971f39040bd0563f01065542 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 21 Aug 2014 00:51:18 +0200 Subject: [PATCH] bbcode: Don't use a preview picture in the "attachment" element if it is a video attachment. --- include/bbcode.php | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 7cf8b71fe5..8f973c9486 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -11,11 +11,11 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $type = ""; preg_match("/type='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") - $type = $matches[1]; + $type = strtolower($matches[1]); preg_match('/type="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") - $type = $matches[1]; + $type = strtolower($matches[1]); if ($type == "") return($match[0]); @@ -42,22 +42,26 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $title = $matches[1]; $image = ""; - preg_match("/image='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; - - preg_match('/image="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; + if ($type != "video") { + preg_match("/image='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + + preg_match('/image="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + } $preview = ""; - preg_match("/preview='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; - - preg_match('/preview="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; + if ($type != "video") { + preg_match("/preview='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + + preg_match('/preview="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + } if ($plaintext) $text = sprintf('%s', $url, $title); @@ -156,6 +160,10 @@ function bb_cleanup_share($shared, $plaintext, $nolink) { if (($text == "") AND ($title != "") AND ($link == "")) $text .= "\n\n".trim($title); + // If the link already is included in the post, don't add it again + if (($link != "") AND strpos($text, $link)) + return(trim($text)); + if (($link != "") AND ($title != "")) $text .= "\n[url=".trim($link)."]".trim($title)."[/url]"; elseif (($link != "")) -- 2.39.5