Update ParseUrl::getSiteinfo type recognition

- Added obsolete twitter card type provision
This commit is contained in:
Hypolite Petovan 2018-09-02 17:50:27 -04:00
parent 8bcc3c6860
commit 9744f0e780

View file

@ -248,55 +248,61 @@ class ParseUrl
} }
} }
if (!empty($meta_tag['content'])) { if (empty($meta_tag['content'])) {
$meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8')); continue;
}
switch (strtolower($meta_tag['name'])) { $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8'));
case 'fulltitle':
$siteinfo['title'] = trim($meta_tag['content']); switch (strtolower($meta_tag['name'])) {
break; case 'fulltitle':
case 'description': $siteinfo['title'] = trim($meta_tag['content']);
$siteinfo['text'] = trim($meta_tag['content']); break;
break; case 'description':
case 'thumbnail': $siteinfo['text'] = trim($meta_tag['content']);
$siteinfo['image'] = $meta_tag['content']; break;
break; case 'thumbnail':
case 'twitter:image': $siteinfo['image'] = $meta_tag['content'];
$siteinfo['image'] = $meta_tag['content']; break;
break; case 'twitter:image':
case 'twitter:image:src': $siteinfo['image'] = $meta_tag['content'];
$siteinfo['image'] = $meta_tag['content']; break;
break; case 'twitter:image:src':
case 'twitter:card': $siteinfo['image'] = $meta_tag['content'];
if (($siteinfo['type'] == '') || ($meta_tag['content'] == 'photo')) { break;
$siteinfo['type'] = $meta_tag['content']; case 'twitter:card':
} // Obsolete card type
break; if ($meta_tag['content'] == 'photo') {
case 'twitter:description': $siteinfo['type'] = 'summary_large_image';
$siteinfo['text'] = trim($meta_tag['content']); } else {
break; $siteinfo['type'] = $meta_tag['content'];
case 'twitter:title': }
$siteinfo['title'] = trim($meta_tag['content']); break;
break; case 'twitter:description':
case 'dc.title': $siteinfo['text'] = trim($meta_tag['content']);
$siteinfo['title'] = trim($meta_tag['content']); break;
break; case 'twitter:title':
case 'dc.description': $siteinfo['title'] = trim($meta_tag['content']);
$siteinfo['text'] = trim($meta_tag['content']); break;
break; case 'dc.title':
case 'keywords': $siteinfo['title'] = trim($meta_tag['content']);
$keywords = explode(',', $meta_tag['content']); break;
break; case 'dc.description':
case 'news_keywords': $siteinfo['text'] = trim($meta_tag['content']);
$keywords = explode(',', $meta_tag['content']); break;
break; case 'keywords':
} $keywords = explode(',', $meta_tag['content']);
} break;
if ($siteinfo['type'] == 'summary') { case 'news_keywords':
$siteinfo['type'] = 'link'; $keywords = explode(',', $meta_tag['content']);
break;
} }
} }
if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') {
$siteinfo['type'] = 'link';
}
if (isset($keywords)) { if (isset($keywords)) {
$siteinfo['keywords'] = []; $siteinfo['keywords'] = [];
foreach ($keywords as $keyword) { foreach ($keywords as $keyword) {