Optional parameter for parseurl to only fetch data from meta information
This commit is contained in:
parent
70e017745a
commit
4f38969148
|
@ -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){
|
||||
|
@ -68,7 +68,7 @@ function oembed_fetch_url($embedurl){
|
|||
|
||||
function oembed_format_object($j){
|
||||
$a = get_app();
|
||||
$embedurl = $j->embedurl;
|
||||
$embedurl = $j->embedurl;
|
||||
$jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) );
|
||||
$ret="<span class='oembed ".$j->type."'>";
|
||||
switch ($j->type) {
|
||||
|
@ -110,11 +110,13 @@ function oembed_format_object($j){
|
|||
}
|
||||
|
||||
// add link to source if not present in "rich" type
|
||||
if ( $j->type!='rich' || !strpos($j->html,$embedurl) ){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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']");
|
||||
|
|
Loading…
Reference in a new issue