X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FLinkPreview%2FLinkPreviewPlugin.php;h=2cc077d90e7b030a41ee82169b2a2907e3ceab6b;hb=74387e75cf1f521bfdea0a8d635730ee6fb49d9d;hp=d887ca0408a6ad3492753acce547967c5e0f41aa;hpb=450707fec626e4e2b2eed4e46591fcf06368d0a1;p=quix0rs-gnu-social.git diff --git a/plugins/LinkPreview/LinkPreviewPlugin.php b/plugins/LinkPreview/LinkPreviewPlugin.php index d887ca0408..2cc077d90e 100644 --- a/plugins/LinkPreview/LinkPreviewPlugin.php +++ b/plugins/LinkPreview/LinkPreviewPlugin.php @@ -50,8 +50,19 @@ class LinkPreviewPlugin extends Plugin function onEndShowScripts($action) { $user = common_current_user(); - if ($user) { - $action->script('plugins/LinkPreview/linkpreview.js'); + if ($user && common_config('attachments', 'process_links')) { + if (common_config('site', 'minify')) { + $js = 'linkpreview.min.js'; + } else { + $js = 'linkpreview.js'; + } + $action->script($this->path($js)); + $data = json_encode(array( + 'api' => common_local_url('oembedproxy'), + 'width' => common_config('attachments', 'thumbwidth'), + 'height' => common_config('attachments', 'thumbheight'), + )); + $action->inlineScript('$(function() {SN.Init.LinkPreview && SN.Init.LinkPreview('.$data.');})'); } return true; } @@ -67,10 +78,11 @@ class LinkPreviewPlugin extends Plugin */ function onAutoload($cls) { - switch ($cls) + $lower = strtolower($cls); + switch ($lower) { - case 'LinkpreviewAction': - require_once dirname(__FILE__) . '/linkpreviewaction.php'; + case 'oembedproxyaction': + require_once dirname(__FILE__) . '/' . $lower . '.php'; return false; default: return true; @@ -86,8 +98,8 @@ class LinkPreviewPlugin extends Plugin */ function onStartInitializeRouter($m) { - $m->connect('main/preview/link', - array('action' => 'linkpreview')); + $m->connect('main/oembed/proxy', + array('action' => 'oembedproxy')); return true; }