X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=1f45d2814325449ce5816e564fd7545b9ea2a4c9;hb=355c42cb309eb1313097411067ca999b699aa620;hp=3e86627e4dd384683a96e834bd8ec56503ce90a3;hpb=dc212de9606422be6e912a0bb7f3569192942938;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php index 3e86627e4d..1f45d28143 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -1,6 +1,6 @@ query("//link[@type='application/json+oembed']"); - foreach($entries as $e){ - $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href); + if (!in_array($ext, $noexts)){ + // try oembed autodiscovery + $redirects = 0; + $html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); + if($html_text){ + $dom = @DOMDocument::loadHTML($html_text); + if ($dom){ + $xpath = new DOMXPath($dom); + $attr = "oembed"; + + $xattr = oe_build_xpath("class","oembed"); + $entries = $xpath->query("//link[@type='application/json+oembed']"); + foreach($entries as $e){ + $href = $e->getAttributeNode("href")->nodeValue; + $txt = fetch_url($href . '&maxwidth=425'); + break; + } } } } if ($txt==false || $txt==""){ // try oohembed service - $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl); + $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=425'; $txt = fetch_url($ourl); } @@ -56,7 +66,7 @@ function oembed_fetch_url($embedurl){ function oembed_format_object($j){ $embedurl = $j->embedurl; - $jhtml = oembed_iframe($j->html,$j->width,$j->height ); + $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) ); $ret=""; switch ($j->type) { case "video": { @@ -116,7 +126,9 @@ function oembed_iframe($src,$width,$height) { $height = intval($height) + 80; $width = intval($width) + 40; - $s = 'data:text/html;base64,' . base64_encode('' . $src . ''); + $a = get_app(); + + $s = $a->get_baseurl()."/oembed/".base64url_encode($src); return ''; }