aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Thumbnailer.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-11-09 18:57:02 +0100
committerArthurHoaro <arthur@hoa.ro>2018-07-05 20:31:35 +0200
commit1b93137e16694f52952c930848e1a7928e8a00a6 (patch)
tree3d2c69d1c3bd1a85e1e46b04c55fc3978b5ebde8 /application/Thumbnailer.php
parentedb4a4d9c9fbc01d67ee8d095fe26648714e2285 (diff)
downloadShaarli-1b93137e16694f52952c930848e1a7928e8a00a6.tar.gz
Shaarli-1b93137e16694f52952c930848e1a7928e8a00a6.tar.zst
Shaarli-1b93137e16694f52952c930848e1a7928e8a00a6.zip
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 #345 #425 #487 #543 #588 #590
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}