Prevent false "photo" page detection
This commit is contained in:
parent
25c5bd256c
commit
2ed98bd040
1 changed files with 8 additions and 3 deletions
|
@ -349,6 +349,9 @@ class ParseUrl
|
||||||
$siteinfo['title'] = trim($list->item(0)->nodeValue);
|
$siteinfo['title'] = trim($list->item(0)->nodeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$twitter_card = false;
|
||||||
|
$twitter_image = false;
|
||||||
|
|
||||||
$list = $xpath->query('//meta[@name]');
|
$list = $xpath->query('//meta[@name]');
|
||||||
foreach ($list as $node) {
|
foreach ($list as $node) {
|
||||||
$meta_tag = [];
|
$meta_tag = [];
|
||||||
|
@ -376,6 +379,7 @@ class ParseUrl
|
||||||
break;
|
break;
|
||||||
case 'twitter:image':
|
case 'twitter:image':
|
||||||
$siteinfo['image'] = $meta_tag['content'];
|
$siteinfo['image'] = $meta_tag['content'];
|
||||||
|
$twitter_image = true;
|
||||||
break;
|
break;
|
||||||
case 'twitter:image:src':
|
case 'twitter:image:src':
|
||||||
$siteinfo['image'] = $meta_tag['content'];
|
$siteinfo['image'] = $meta_tag['content'];
|
||||||
|
@ -383,7 +387,7 @@ class ParseUrl
|
||||||
case 'twitter:card':
|
case 'twitter:card':
|
||||||
// Detect photo pages
|
// Detect photo pages
|
||||||
if ($meta_tag['content'] == 'summary_large_image') {
|
if ($meta_tag['content'] == 'summary_large_image') {
|
||||||
$siteinfo['type'] = 'photo';
|
$twitter_card = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'twitter:description':
|
case 'twitter:description':
|
||||||
|
@ -458,6 +462,7 @@ class ParseUrl
|
||||||
break;
|
break;
|
||||||
case 'twitter:image':
|
case 'twitter:image':
|
||||||
$siteinfo['image'] = $meta_tag['content'];
|
$siteinfo['image'] = $meta_tag['content'];
|
||||||
|
$twitter_image = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,8 +478,8 @@ class ParseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent to have a photo type without an image
|
// Prevent to have a photo type without an image
|
||||||
if ((empty($siteinfo['image']) || !empty($siteinfo['text'])) && ($siteinfo['type'] == 'photo')) {
|
if ($twitter_card && $twitter_image && !empty($siteinfo['image'])) {
|
||||||
$siteinfo['type'] = 'link';
|
$siteinfo['type'] = 'photo';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($siteinfo['image'])) {
|
if (!empty($siteinfo['image'])) {
|
||||||
|
|
Loading…
Reference in a new issue