<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
}
$curlResult = DI::httpRequest()->get($url);
- if (!$curlResult->isSuccess()) {
+ if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return $siteinfo;
}
$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;
}
}
}
}
+// Currently deactivated, see https://github.com/friendica/friendica/pull/10148#issuecomment-821512658
// 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'])) {
$siteinfo['images'] = $siteinfo['images'] ?? [];
array_walk_recursive($siteinfo, function (&$element) {
if (is_string($element)) {
- $element = html_entity_decode($element, ENT_COMPAT, 'UTF-8');
+ $element = trim(strip_tags(html_entity_decode($element, ENT_COMPAT, 'UTF-8')));
}
});