$siteinfo['image'] = $meta_tag['content'];
break;
case 'twitter:card':
- // Obsolete card type
- if ($meta_tag['content'] == 'photo') {
- $siteinfo['type'] = 'summary_large_image';
- } else {
- $siteinfo['type'] = $meta_tag['content'];
+ // Detect photo pages
+ if ($meta_tag['content'] == 'summary_large_image') {
+ $siteinfo['type'] = 'photo';
}
break;
case 'twitter:description':
}
}
- if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') {
- $siteinfo['type'] = 'link';
- }
-
if (isset($keywords)) {
$siteinfo['keywords'] = [];
foreach ($keywords as $keyword) {
}
}
+ // Prevent to have a photo type without an image
+ if ((empty($siteinfo['image']) || !empty($siteinfo['text'])) && ($siteinfo['type'] == 'photo')) {
+ $siteinfo['type'] = 'link';
+ }
+
if ((@$siteinfo['image'] == '') && !$no_guessing) {
$list = $xpath->query('//img[@src]');
foreach ($list as $node) {
$complete = $schemearr["scheme"]."://".$schemearr["host"];
- if (@$schemearr["port"] != "") {
+ if (!empty($schemearr["port"])) {
$complete .= ":".$schemearr["port"];
}
- if (strpos($urlarr["path"], "/") !== 0) {
- $complete .= "/";
- }
+ if (!empty($urlarr["path"])) {
+ if (strpos($urlarr["path"], "/") !== 0) {
+ $complete .= "/";
+ }
- $complete .= $urlarr["path"];
+ $complete .= $urlarr["path"];
+ }
- if (@$urlarr["query"] != "") {
+ if (!empty($urlarr["query"])) {
$complete .= "?".$urlarr["query"];
}
- if (@$urlarr["fragment"] != "") {
+ if (!empty($urlarr["fragment"])) {
$complete .= "#".$urlarr["fragment"];
}