aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Thumbnailer.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Thumbnailer.php')
-rw-r--r--application/Thumbnailer.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php
new file mode 100644
index 00000000..b669adae
--- /dev/null
+++ b/application/Thumbnailer.php
@@ -0,0 +1,49 @@
1<?php
2
3use WebThumbnailer\WebThumbnailer;
4
5/**
6 * Class Thumbnailer
7 *
8 * Utility class used to retrieve thumbnails using web-thumbnailer dependency.
9 */
10class 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}