diff --git a/include/bbcode.php b/include/bbcode.php
index ef791d9e7..1eac012c3 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -4,7 +4,7 @@ require_once('include/event.php');
function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
- function ($match) use ($plaintext){
+ function ($match) use ($plaintext, $tryoembed){
$attributes = $match[2];
@@ -83,14 +83,18 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
else
$oembed = $bookmark[0];
- if (($image != "") AND !strstr(strtolower($oembed), "
', $url, $image, $title);
- elseif (($preview != "") AND !strstr(strtolower($oembed), "
', $url, $preview, $title);
+ if (strstr(strtolower($oembed), "