diff --git a/include/bbcode.php b/include/bbcode.php
index c2d9326748..b2e9cee6df 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -92,17 +92,22 @@ function bbcode($Text,$preserve_nl = false) {
// [img=widthxheight]image source[/img]
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text);
- // Youtube extensions
+ $a = get_app();
+ if ($a->config['system']['embed_all']){
+ // use oembed for youtube links
+ $Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
+ $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
+ } else {
+ // Youtube extensions
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
-
- $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '
', $Text);
-
-// $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '
', $Text);
+ $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text);
+ }
+// $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text);
// oembed tag
$Text = oembed_bbcode2html($Text);
-
+
call_hooks('bbcode',$Text);
return $Text;
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 30371e9f6a..8e16847325 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -1,7 +1,7 @@
config['system']['embed_all']){
+ $j = oembed_fetch_url($url);
+ if ($j->type!="error"){
+ echo oembed_format_object($j);
+ killme();
+ }
+ }
+
$s = fetch_url($url);
- else {
+ } else {
echo '';
killme();
}