]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
Merge pull request #3279 from Hypolite/improvement/add-composer
[friendica.git] / include / oembed.php
index 2490e5ecaa34f20c156ef7845437b37191f0f21c..0b8b713667e7aa1faede525a5a08db1b07b03c0b 100755 (executable)
@@ -17,10 +17,10 @@ function oembed_replacecb($matches){
 
 /**
  * @brief Get data from an URL to embed its content.
- * 
+ *
  * @param string $embedurl The URL from which the data should be fetched.
  * @param bool $no_rich_type If set to true rich type content won't be fetched.
- * 
+ *
  * @return bool|object Returns object with embed content or false if no embedable
  *      content exists
  */
@@ -41,8 +41,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
        // These media files should now be caught in bbcode.php
        // left here as a fallback in case this is called from another source
 
-       $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm");
-       $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
+       $noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
+       $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
 
 
        if (is_null($txt)) {
@@ -74,21 +74,10 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
                        }
                }
 
-               if ($txt==false || $txt=="") {
-                       $embedly = Config::get("system", "embedly");
-                       if ($embedly != "") {
-                               // try embedly service
-                               $ourl = "https://api.embed.ly/1/oembed?key=".$embedly."&url=".urlencode($embedurl);
-                               $txt = fetch_url($ourl);
+               $txt = trim($txt);
 
-                               logger("oembed_fetch_url: ".$txt, LOGGER_DEBUG);
-                       }
-               }
-
-               $txt=trim($txt);
-
-               if ($txt[0]!="{") {
-                       $txt='{"type":"error"}';
+               if ($txt[0] != "{") {
+                       $txt = '{"type":"error"}';
                } else {        //save in cache
                        $j = json_decode($txt);
                        if ($j->type != "error") {
@@ -316,9 +305,7 @@ function oembed_html2bbcode($text) {
                $xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
                foreach($entries as $e) {
                        $href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
-                       if (!is_null($href)) {
-                               $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
-                       }
+                       if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
                }
                return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
        } else {