Oembed slimmed to only do discovery (soon we get og: discovery too)

This commit is contained in:
Mikael Nordfeldth
2015-11-30 02:06:04 +01:00
parent 8bab642cc7
commit 334a0d56e7
4 changed files with 46 additions and 110 deletions

View File

@@ -35,6 +35,24 @@ class OembedPlugin extends Plugin
$m->connect('main/oembed', array('action' => 'oembed'));
}
public function onGetRemoteUrlMetadataFromDom($url, DOMDocument $dom, stdClass &$metadata)
{
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);
$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.');
// Just ignore it!
}
}
public function onEndShowHeadElements(Action $action)
{
switch ($action->getActionName()) {