Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting custom thumbnails #226

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ function showDailyRSS()
{
$l = $LINKSDB[$linkdate];
$l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($l['description']))));
$l['thumbnail'] = thumbnail($l['url']);
$l['thumbnail'] = thumbnail($l['url'], isset($l['thumb']) ? $l['thumb'] : False);
$l['localdate']=linkdate2locale($l['linkdate']);
if (startsWith($l['url'],'?')) $l['url']=indexUrl().$l['url']; // make permalink URL absolute
$links[$linkdate]=$l;
Expand Down Expand Up @@ -1152,7 +1152,7 @@ function showDaily()
uasort($taglist, 'strcasecmp');
$linksToDisplay[$key]['taglist']=$taglist;
$linksToDisplay[$key]['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))));
$linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']);
$linksToDisplay[$key]['thumbnail'] = thumbnail($link['url'], isset($link['thumb']) ? $link['thumb'] : False);
}

/* We need to spread the articles on 3 columns.
Expand Down Expand Up @@ -1232,7 +1232,7 @@ function renderPage()
foreach($links as $link)
{
$permalink='?'.htmlspecialchars(smallhash($link['linkdate']),ENT_QUOTES);
$thumb=lazyThumbnail($link['url'],$permalink);
$thumb=lazyThumbnail($link['url'], isset($link['thumb']) ? $link['thumb'] : False);
if ($thumb!='') // Only output links which have a thumbnail.
{
$link['thumbnail']=$thumb; // Thumbnail HTML code.
Expand Down Expand Up @@ -1482,10 +1482,11 @@ function renderPage()
$tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces.
$linkdate=$_POST['lf_linkdate'];
$url = trim($_POST['lf_url']);
$thumb = trim($_POST['lf_thumb']);
if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?'))
$url = 'http://'.$url;
$link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags),'thumb'=>$thumb);
if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
$LINKSDB[$linkdate] = $link;
$LINKSDB->savedb(); // save to disk
Expand Down Expand Up @@ -1885,7 +1886,8 @@ function buildLinkList($PAGE,$LINKSDB)
function computeThumbnail($url,$href=false)
{
if (!$GLOBALS['config']['ENABLE_THUMBNAILS']) return array();
if ($href==false) $href=$url;
if ($href!=false and !empty($href)) $url=$href;


// For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link.
// (eg. http://www.youtube.com/watch?v=spVypYk4kto ---> http://img.youtube.com/vi/spVypYk4kto/default.jpg )
Expand Down
3 changes: 2 additions & 1 deletion tpl/editlink.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<i>Title</i><br><input type="text" name="lf_title" value="{$link.title|htmlspecialchars}" style="width:100%"><br>
<i>Description</i><br><textarea name="lf_description" rows="4" cols="25" style="width:100%">{$link.description|htmlspecialchars}</textarea><br>
<i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
<i>Thumbnail</i><br><input type="text" name="lf_thumb" value="{function="isset($link['thumb']) ? htmlspecialchars($link['thumb']) : """}" style="width:100%"><br>
{if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
<input type="checkbox" checked="checked" name="lf_private" id="lf_private">
&nbsp;<label for="lf_private"><i>Private</i></label><br>
Expand All @@ -41,4 +42,4 @@
</script>
{/if}
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion tpl/linklist.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{loop="links"}
<li{if="$value.class"} class="{$value.class}"{/if}>
<a name="{$value.linkdate|smallHash}" id="{$value.linkdate|smallHash}"></a>
<div class="thumbnail">{$value.url|thumbnail}</div>
<div class="thumbnail">{function="thumbnail($value['url'], isset($value['thumb']) ? $value['thumb'] : False)"}</div>
<div class="linkcontainer">
{if="isLoggedIn()"}
<div class="linkeditbuttons">
Expand Down