Optional parameter for parseurl to only fetch data from meta information

This commit is contained in:
Michael Vogel 2013-12-02 20:24:41 +01:00
parent 70e017745a
commit 4f38969148
2 changed files with 31 additions and 32 deletions

View File

@ -29,7 +29,7 @@ function oembed_fetch_url($embedurl){
if (!in_array($ext, $noexts)){
// try oembed autodiscovery
$redirects = 0;
$html_text = fetch_url($embedurl, false, $redirects, 15, "text/*");
$html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); /**/
if($html_text){
$dom = @DOMDocument::loadHTML($html_text);
if ($dom){
@ -111,10 +111,12 @@ function oembed_format_object($j){
// add link to source if not present in "rich" type
if ($j->type!='rich' || !strpos($j->html,$embedurl) ){
if (isset($j->provider_name)) $ret .= $j->provider_name.": ";
$embedlink = (isset($j->title))?$j->title:$embedurl;
$ret .= "<a href='$embedurl' rel='oembed'>$embedlink</a>";
if (isset($j->author_name)) $ret.=" by ".$j->author_name;
if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
if (isset($j->author_name)) $ret.=" (".$j->author_name.")";
//if (isset($j->author_name)) $ret.=" by ".$j->author_name;
//if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
} else {
// add <a> for html2bbcode conversion
$ret .= "<a href='$embedurl' rel='oembed'></a>";
@ -195,6 +197,3 @@ function oembed_html2bbcode($text) {
return $text;
}
}

View File

@ -50,7 +50,7 @@ function completeurl($url, $scheme) {
return($complete);
}
function parseurl_getsiteinfo($url) {
function parseurl_getsiteinfo($url, $no_guessing = false) {
$siteinfo = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@ -184,7 +184,7 @@ function parseurl_getsiteinfo($url) {
}
}
if (@$siteinfo["image"] == "") {
if ((@$siteinfo["image"] == "") AND !$no_guessing) {
$list = $xpath->query("//img[@src]");
foreach ($list as $node) {
$attr = array();
@ -223,7 +223,7 @@ function parseurl_getsiteinfo($url) {
"height"=>$photodata[1]);
}
if (@$siteinfo["text"] == "") {
if ((@$siteinfo["text"] == "") AND (@$siteinfo["title"] != "") AND !$no_guessing) {
$text = "";
$list = $xpath->query("//div[@class='article']");