Add thumbshot key
This commit is contained in:
parent
d923d1db2f
commit
7a4ff2cd78
2 changed files with 13 additions and 3 deletions
|
@ -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))"
|
||||
|
|
|
@ -37,6 +37,9 @@ function myShaarli_init($conf)
|
|||
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 = '&hm='.hash_hmac('sha1', $value['url'], $key).'&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">';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue