forked from shaarli/Shaarli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use web-thumbnailer to retrieve thumbnails
* requires PHP 5.6 * use blazy on linklist since a lot more thumbs are retrieved * thumbnails can be disabled * thumbs size is now 120x120 * thumbs are now cropped to fit the expected size Fixes shaarli#345 shaarli#425 shaarli#487 shaarli#543 shaarli#588 shaarli#590
- Loading branch information
1 parent
f5f6a4b
commit 9950053
Showing
11 changed files
with
222 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use WebThumbnailer\WebThumbnailer; | ||
|
||
/** | ||
* Class Thumbnailer | ||
* | ||
* Utility class used to retrieve thumbnails using web-thumbnailer dependency. | ||
*/ | ||
class Thumbnailer | ||
{ | ||
/** | ||
* @var WebThumbnailer instance. | ||
*/ | ||
protected $wt; | ||
|
||
/** | ||
* @var ConfigManager instance. | ||
*/ | ||
protected $conf; | ||
|
||
/** | ||
* Thumbnailer constructor. | ||
* | ||
* @param ConfigManager $conf instance. | ||
*/ | ||
public function __construct($conf) | ||
{ | ||
$this->conf = $conf; | ||
$this->wt = new WebThumbnailer(); | ||
\WebThumbnailer\Application\ConfigManager::addFile('inc/web-thumbnailer.json'); | ||
$this->wt->maxWidth($this->conf->get('thumbnails.width')) | ||
->maxHeight($this->conf->get('thumbnails.height')) | ||
->crop(true); | ||
} | ||
|
||
/** | ||
* Retrieve a thumbnail for given URL | ||
* | ||
* @param string $url where to look for a thumbnail. | ||
* | ||
* @return bool|string The thumbnail relative cache file path, or false if none has been found. | ||
*/ | ||
public function get($url) | ||
{ | ||
return $this->wt->thumbnail($url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"settings": { | ||
"default": { | ||
"_comment": "infinite cache", | ||
"cache_duration": -1 | ||
} | ||
} | ||
} |
Oops, something went wrong.