aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Thumbnailer.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-04-06 18:21:47 +0200
committerArthurHoaro <arthur@hoa.ro>2018-07-05 20:34:22 +0200
commit787faa42f3a2bcbf83a7853f23f3667a6febf9da (patch)
treec24e9da3affe84820cf40c4d1904c2621de6d828 /application/Thumbnailer.php
parent8b5b7dcc831a0ff1c660a0c0bca5d3cec376a5fc (diff)
downloadShaarli-787faa42f3a2bcbf83a7853f23f3667a6febf9da.tar.gz
Shaarli-787faa42f3a2bcbf83a7853f23f3667a6febf9da.tar.zst
Shaarli-787faa42f3a2bcbf83a7853f23f3667a6febf9da.zip
Take code review into account
Upgrade web-thumbnailer and display thumbs right after download
Diffstat (limited to 'application/Thumbnailer.php')
-rw-r--r--application/Thumbnailer.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php
index 9cf5dacd..d2284e79 100644
--- a/application/Thumbnailer.php
+++ b/application/Thumbnailer.php
@@ -32,6 +32,14 @@ class Thumbnailer
32 public function __construct($conf) 32 public function __construct($conf)
33 { 33 {
34 $this->conf = $conf; 34 $this->conf = $conf;
35
36 if (! $this->checkRequirements()) {
37 $this->conf->set('thumbnails.enabled', false);
38 $this->conf->write(true);
39 // TODO: create a proper error handling system able to catch exceptions...
40 die(t('php-gd extension must be loaded to use thumbnails. Thumbnails are now disabled. Please reload the page.'));
41 }
42
35 $this->wt = new WebThumbnailer(); 43 $this->wt = new WebThumbnailer();
36 WTConfigManager::addFile('inc/web-thumbnailer.json'); 44 WTConfigManager::addFile('inc/web-thumbnailer.json');
37 $this->wt->maxWidth($this->conf->get('thumbnails.width')) 45 $this->wt->maxWidth($this->conf->get('thumbnails.width'))
@@ -57,4 +65,13 @@ class Thumbnailer
57 return false; 65 return false;
58 } 66 }
59 } 67 }
68
69 /**
70 * Make sure that requirements are match to use thumbnails:
71 * - php-gd is loaded
72 */
73 protected function checkRequirements()
74 {
75 return extension_loaded('gd');
76 }
60} 77}