return $result;
}
- $type = ParseUrl::getContentType($url);
+ $siteinfo = ParseUrl::getSiteinfoCached($url);
- if (in_array($type, ['image', 'video', 'audio'])) {
- switch ($type) {
+ if (in_array($siteinfo['type'], ['image', 'video', 'audio'])) {
+ switch ($siteinfo['type']) {
case 'video':
$bbcode = "\n" . '[video]' . $url . '[/video]' . "\n";
break;
return $bbcode;
}
- $siteinfo = ParseUrl::getSiteinfoCached($url);
-
unset($siteinfo['keywords']);
// Bypass attachment if parse url for a comment
}
if ($format == 'json') {
- $type = Util\ParseUrl::getContentType($url);
+ $siteinfo = Util\ParseUrl::getSiteinfoCached($url);
- if (in_array($type, ['image', 'video', 'audio'])) {
- switch ($type) {
+ if (in_array($siteinfo['type'], ['image', 'video', 'audio'])) {
+ switch ($siteinfo['type']) {
case 'video':
$content_type = 'video';
break;
$ret['data'] = ['url' => $url];
$ret['success'] = true;
} else {
- $siteinfo = Util\ParseUrl::getSiteinfoCached($url);
-
unset($siteinfo['keywords']);
$ret['data'] = $siteinfo;
return $siteinfo;
}
+ $type = self::getContentType($url);
+ if (in_array($type, ['image', 'video', 'audio'])) {
+ $siteinfo['type'] = $type;
+ return $siteinfo;
+ }
+
$curlResult = DI::httpRequest()->get($url);
if (!$curlResult->isSuccess()) {
return $siteinfo;
$oembed_data = OEmbed::fetchURL($url);
if (!empty($oembed_data->type)) {
- if (!in_array($oembed_data->type, ['error', 'rich', ''])) {
+ if (!in_array($oembed_data->type, ['error', 'rich', 'image', 'video', 'audio', ''])) {
$siteinfo['type'] = $oembed_data->type;
}