From ef64c5187df80da2065655726b8d05a9ce6b0e0a Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 22 May 2011 23:06:47 +0200 Subject: [PATCH] add config [system][embed_all] to use oembed with links and youtube. Url parse fallback to default if url has not an oembed rappresentation. --- include/bbcode.php | 17 +++++++++++------ mod/parse_url.php | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index c2d93267..b2e9cee6 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 30371e9f..8e168473 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(); }