]>
Commit | Line | Data |
---|---|---|
1b93137e A |
1 | <?php |
2 | ||
3 | use WebThumbnailer\WebThumbnailer; | |
4 | ||
5 | /** | |
6 | * Class Thumbnailer | |
7 | * | |
8 | * Utility class used to retrieve thumbnails using web-thumbnailer dependency. | |
9 | */ | |
10 | class Thumbnailer | |
11 | { | |
12 | /** | |
13 | * @var WebThumbnailer instance. | |
14 | */ | |
15 | protected $wt; | |
16 | ||
17 | /** | |
18 | * @var ConfigManager instance. | |
19 | */ | |
20 | protected $conf; | |
21 | ||
22 | /** | |
23 | * Thumbnailer constructor. | |
24 | * | |
25 | * @param ConfigManager $conf instance. | |
26 | */ | |
27 | public function __construct($conf) | |
28 | { | |
29 | $this->conf = $conf; | |
30 | $this->wt = new WebThumbnailer(); | |
31 | \WebThumbnailer\Application\ConfigManager::addFile('inc/web-thumbnailer.json'); | |
32 | $this->wt->maxWidth($this->conf->get('thumbnails.width')) | |
33 | ->maxHeight($this->conf->get('thumbnails.height')) | |
34 | ->crop(true) | |
35 | ->debug($this->conf->get('dev.debug', false)); | |
36 | } | |
37 | ||
38 | /** | |
39 | * Retrieve a thumbnail for given URL | |
40 | * | |
41 | * @param string $url where to look for a thumbnail. | |
42 | * | |
43 | * @return bool|string The thumbnail relative cache file path, or false if none has been found. | |
44 | */ | |
45 | public function get($url) | |
46 | { | |
47 | return $this->wt->thumbnail($url); | |
48 | } | |
49 | } |