Add thumbshot key

This commit is contained in:
Knah Tsaeb 2018-02-13 11:41:56 +01:00
parent d923d1db2f
commit 7a4ff2cd78
2 changed files with 13 additions and 3 deletions

View file

@ -1,2 +1,4 @@
description="For each link, add thumbshot image and favicon"
parameters=ExternalThumbshot_URL;
parameters="ExternalThumbshot_URL;ExternalThumbshot_KEY"
parameter.ExternalThumbshot_URL="Thumshot service URL"
parameter.ExternalThumbshot_KEY="Thumbshot key (key are hash with hash_hmac('sha1', $url, $key))"

View file

@ -37,6 +37,9 @@
function hook_myShaarli_render_linklist($data,$conf)
{
$thumUrl = $conf->get('plugins.ExternalThumbshot_URL');
if(!empty($conf->get('plugins.ExternalThumbshot_KEY'))){
$key = $conf->get('plugins.ExternalThumbshot_KEY');
}
if (!isset($thumUrl)) {
return $data;
}
@ -44,8 +47,13 @@ function hook_myShaarli_render_linklist($data,$conf)
foreach ($data['links'] as &$value) {
$thumb = computeThumbnail($conf, $value['url']);
if(empty($thumb)){
//$value['thumbnail'] = '<img src="'.$thumUrl.urlencode($value['url']).'" alt="Thumbnail" width="120" height="90">';
$value['thumbnail'] = '<img class="b-lazy" src="#" data-src="'.$thumUrl.urlencode($value['url']).'" alt="Thumbnail" width="120" height="90">';
if(!empty($key)){
$hmac = '&amp;hm='.hash_hmac('sha1', $value['url'], $key).'&amp;url=';
} else {
$hmac = null;
}
$value['thumbnail'] = '<img class="b-lazy" src="#" data-src="'.$thumUrl.$hmac.urlencode($value['url']).'" alt="Thumbnail" width="120" height="90">';
} else {
$value['thumbnail'] = '<img class="b-lazy" src="#" data-src="'.$thumb['src'].'" alt="Thumbnail" width="120" height="90">';
}