]> git.mxchange.org Git - friendica.git/commitdiff
add config [system][embed_all] to use oembed with links and youtube. Url parse fallba...
authorfabrixxm <fabrix.xm@gmail.com>
Sun, 22 May 2011 21:06:47 +0000 (23:06 +0200)
committerFabio Comuni <fabrix.xm@gmail.com>
Mon, 23 May 2011 07:14:57 +0000 (09:14 +0200)
include/bbcode.php
mod/parse_url.php

index c2d9326748e8ff61ec696daf95a29b7a1e3fe5dd..b2e9cee6dfdb544e84ab73b76df69a796ed7f8ec 100644 (file)
@@ -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\]/", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $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\]/", '<br /><iframe style="width:425px;height:349px;padding:10px 0 10px 0;float:left;" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $Text);
-
-//     $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<br /><object style="width:425px;height:350px;" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" style="width:425px;height:350px;" /><![endif]--></object>', $Text);
+               $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<iframe width="425" height="349" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $Text);
+       }
+//     $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
 
        // oembed tag
        $Text = oembed_bbcode2html($Text);
-
+       
        call_hooks('bbcode',$Text);
 
        return $Text;
index 30371e9f6a1e7661e23cad1fbfcf1d43d1d7f15e..8e168473253efb95815b786f1241e501cfc04275 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 require_once('library/HTML5/Parser.php');
-
+require_once('include/oembed.php');
 
 function parse_url_content(&$a) {
 
@@ -25,9 +25,18 @@ function parse_url_content(&$a) {
                killme();
        }
 
-       if($url) 
+       if($url) {
+               // fetch link with oembed
+               if ($a->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();
        }