-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
40 lines (37 loc) · 1.46 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
@include_once __DIR__ . '/vendor/autoload.php';
use Kirby\Cms\App;
use tobimori\ThumbHash;
App::plugin('tobimori/thumbhash', [
'fileMethods' => [
/** @kql-allowed */
'thumbhash' => fn (array $options = []) => ThumbHash::encode($this, $options),
/** @kql-allowed */
'th' => fn (array $options = []) => $this->thumbhash($options),
/** @kql-allowed */
'thumbhashUri' => fn (array $options = []) => ThumbHash::thumb($this, $options),
/** @kql-allowed */
'thUri' => fn (array $options = []) => $this->thumbhashUri($options),
],
'assetMethods' => [
/** @kql-allowed */
'thumbhash' => fn (array $options = []) => ThumbHash::encode($this, $options),
/** @kql-allowed */
'th' => fn (array $options = []) => $this->thumbhash($options),
/** @kql-allowed */
'thumbhashUri' => fn (array $options = []) => ThumbHash::thumb($this, $options),
/** @kql-allowed */
'thUri' => fn (array $options = []) => $this->thumbhashUri($options),
],
'options' => [
'cache.encode' => true,
'cache.decode' => true,
//'engine' => 'gd', // `gd` or `imagick` - TODO
'blurRadius' => 1, // Blur radius, larger values are smoother, but less accurate
'sampleMaxSize' => 100, // Max width or height for smaller image that gets encoded (Memory constraints)
],
'hooks' => [
'file.update:before' => fn ($file) => ThumbHash::clearCache($file),
'file.replace:before' => fn ($file) => ThumbHash::clearCache($file),
]
]);