parse url: Improvements for detecting the page type
This commit is contained in:
parent
dab71c7b3b
commit
b013537124
|
@ -82,6 +82,9 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
|
||||||
|
|
||||||
$oembed_data = oembed_fetch_url($url);
|
$oembed_data = oembed_fetch_url($url);
|
||||||
|
|
||||||
|
if ($oembed_data->type != "error")
|
||||||
|
$siteinfo["type"] = $oembed_data->type;
|
||||||
|
|
||||||
if ($oembed_data->type == "link") {
|
if ($oembed_data->type == "link") {
|
||||||
if (isset($oembed_data->title))
|
if (isset($oembed_data->title))
|
||||||
$siteinfo["title"] = $oembed_data->title;
|
$siteinfo["title"] = $oembed_data->title;
|
||||||
|
@ -172,7 +175,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
|
||||||
$siteinfo["image"] = $attr["content"];
|
$siteinfo["image"] = $attr["content"];
|
||||||
break;
|
break;
|
||||||
case "twitter:card":
|
case "twitter:card":
|
||||||
$siteinfo["type"] = $attr["content"];
|
if ($siteinfo["type"] == "")
|
||||||
|
$siteinfo["type"] = $attr["content"];
|
||||||
break;
|
break;
|
||||||
case "twitter:description":
|
case "twitter:description":
|
||||||
$siteinfo["text"] = $attr["content"];
|
$siteinfo["text"] = $attr["content"];
|
||||||
|
@ -187,6 +191,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
|
||||||
$siteinfo["text"] = $attr["content"];
|
$siteinfo["text"] = $attr["content"];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ($siteinfo["type"] == "summary")
|
||||||
|
$siteinfo["type"] = "link";
|
||||||
}
|
}
|
||||||
|
|
||||||
//$list = $xpath->query("head/meta[@property]");
|
//$list = $xpath->query("head/meta[@property]");
|
||||||
|
@ -391,7 +397,7 @@ function parse_url_content(&$a) {
|
||||||
$total_images ++;
|
$total_images ++;
|
||||||
if($max_images && $max_images >= $total_images)
|
if($max_images && $max_images >= $total_images)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen($text)) {
|
if(strlen($text)) {
|
||||||
|
@ -414,7 +420,9 @@ function parse_url_content(&$a) {
|
||||||
|
|
||||||
$sitedata .= trim($result);
|
$sitedata .= trim($result);
|
||||||
|
|
||||||
if (($siteinfo["type"] != "photo"))
|
if (($siteinfo["type"] == "video") AND ($url != ""))
|
||||||
|
echo "[video]".$url."[/video]";
|
||||||
|
elseif (($siteinfo["type"] != "photo"))
|
||||||
echo "[class=type-link]".$sitedata."[/class]";
|
echo "[class=type-link]".$sitedata."[/class]";
|
||||||
else
|
else
|
||||||
echo "[class=type-photo]".$title.$br.$image."[/class]";
|
echo "[class=type-photo]".$title.$br.$image."[/class]";
|
||||||
|
|
Loading…
Reference in a new issue