$oembed->type = $data['type'];
if ($oembed->type == 'photo') {
- $oembed->url = $data['url'];
+ if (!empty($data['images'])) {
+ $oembed->url = $data['images'][0]['src'];
+ $oembed->width = $data['images'][0]['width'];
+ $oembed->height = $data['images'][0]['height'];
+ } else {
+ $oembed->type = 'link';
+ }
}
}
$oembed->author_url = $data['author_url'];
}
- if (!empty($data['images'])) {
+ if (!empty($data['images']) && ($oembed->type != 'photo')) {
$oembed->thumbnail_url = $data['images'][0]['src'];
$oembed->thumbnail_width = $data['images'][0]['width'];
$oembed->thumbnail_height = $data['images'][0]['height'];
$siteinfo['title'] = trim($list->item(0)->nodeValue);
}
+ $twitter_card = false;
+ $twitter_image = false;
+
$list = $xpath->query('//meta[@name]');
foreach ($list as $node) {
$meta_tag = [];
break;
case 'twitter:image':
$siteinfo['image'] = $meta_tag['content'];
+ $twitter_image = true;
break;
case 'twitter:image:src':
$siteinfo['image'] = $meta_tag['content'];
case 'twitter:card':
// Detect photo pages
if ($meta_tag['content'] == 'summary_large_image') {
- $siteinfo['type'] = 'photo';
+ $twitter_card = true;
}
break;
case 'twitter:description':
break;
case 'twitter:image':
$siteinfo['image'] = $meta_tag['content'];
+ $twitter_image = true;
break;
}
}
}
// Prevent to have a photo type without an image
- if ((empty($siteinfo['image']) || !empty($siteinfo['text'])) && ($siteinfo['type'] == 'photo')) {
- $siteinfo['type'] = 'link';
+ if ($twitter_card && $twitter_image && !empty($siteinfo['image'])) {
+ $siteinfo['type'] = 'photo';
}
if (!empty($siteinfo['image'])) {