Super-basic OpenGraph image preview support, "works for me"

This commit is contained in:
Mikael Nordfeldth
2016-01-12 15:29:03 +01:00
parent f4feef477b
commit 3658774429
2 changed files with 71 additions and 3 deletions

View File

@@ -40,16 +40,16 @@ class OembedPlugin extends Plugin
try {
common_log(LOG_INFO, 'Trying to discover an oEmbed endpoint using link headers.');
$api = oEmbedHelper::oEmbedEndpointFromHTML($dom);
common_log(LOG_INFO, 'Found API endpoint ' . $api . ' for URL ' . $url);
common_log(LOG_INFO, 'Found oEmbed API endpoint ' . $api . ' for URL ' . $url);
$params = array(
'maxwidth' => common_config('thumbnail', 'width'),
'maxheight' => common_config('thumbnail', 'height'),
);
$metadata = oEmbedHelper::getOembedFrom($api, $url, $params);
} catch (Exception $e) {
common_log(LOG_INFO, 'Could not find an oEmbed endpoint using link headers.');
common_log(LOG_INFO, 'Could not find an oEmbed endpoint using link headers, trying OpenGraph from HTML.');
// Just ignore it!
$metadata = OpenGraphHelper::ogFromHtml($dom);
}
}