X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Foembed.php;h=a4452586eebb1cd79bd904fc81603ca8bab381a2;hb=111ace5abd855a0c4f248b34d468285b825abbd0;hp=7c0da459409c2859ac543cfa88cf79f6a4450cf4;hpb=ab6bf767df4a06494b314f7d0c3928a795b81bae;p=friendica.git diff --git a/include/oembed.php b/include/oembed.php old mode 100644 new mode 100755 index 7c0da45940..a4452586ee --- 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); } @@ -55,8 +65,9 @@ function oembed_fetch_url($embedurl){ } function oembed_format_object($j){ - $embedurl = $j->embedurl; - $jhtml = oembed_iframe($j->embedurl,$j->width,$j->height ); + $a = get_app(); + $embedurl = $j->embedurl; + $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) ); $ret=""; switch ($j->type) { case "video": { @@ -68,6 +79,7 @@ function oembed_format_object($j){ $th=120; $tw = $th*$tr; $tpl=get_markup_template('oembed_video.tpl'); $ret.=replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), '$embedurl'=>$embedurl, '$escapedhtml'=>base64_encode($jhtml), '$tw'=>$tw, @@ -81,7 +93,8 @@ function oembed_format_object($j){ $ret.="
"; }; break; case "photo": { - $ret.= ""; + $ret.= ""; + //$ret.= ""; $ret.="
"; }; break; case "link": {