5 use Shaarli\Config\ConfigManager
;
6 use WebThumbnailer\Exception\WebThumbnailerException
;
7 use WebThumbnailer\WebThumbnailer
;
8 use WebThumbnailer\Application\ConfigManager
as WTConfigManager
;
13 * Utility class used to retrieve thumbnails using web-thumbnailer dependency.
18 * @var WebThumbnailer instance.
23 * @var ConfigManager instance.
28 * Thumbnailer constructor.
30 * @param ConfigManager $conf instance.
32 public function __construct($conf)
35 $this->wt
= new WebThumbnailer();
36 WTConfigManager
::addFile('inc/web-thumbnailer.json');
37 $this->wt
->maxWidth($this->conf
->get('thumbnails.width'))
38 ->maxHeight($this->conf
->get('thumbnails.height'))
40 ->debug($this->conf
->get('dev.debug', false));
44 * Retrieve a thumbnail for given URL
46 * @param string $url where to look for a thumbnail.
48 * @return bool|string The thumbnail relative cache file path, or false if none has been found.
50 public function get($url)
53 return $this->wt
->thumbnail($url);
54 } catch (WebThumbnailerException
$e) {
55 // Exceptions are only thrown in debug mode.
56 error_log(get_class($e) .': '. $e->getMessage());