-
Notifications
You must be signed in to change notification settings - Fork 5
/
routes.php
40 lines (33 loc) · 1.11 KB
/
routes.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
use ABWebDevelopers\ImageResize\Classes\Resizer;
use ABWebDevelopers\ImageResize\Models\ImagePermalink;
use Illuminate\Support\Facades\Cache;
/**
* Publicly accessible URL for resizing an image (lazy-resize), using a cache hash/ext.
*/
Route::get('imageresize/{hash}.{ext}', function (string $hash, string $ext) {
$config = Cache::get(Resizer::CACHE_PREFIX . $hash);
if (empty($config)) {
$config = [
'image' => null,
'options' => [],
'formatCache' => [],
];
}
return Resizer::using($config['image'])
->setHash($hash)
->setOptions($config['options'] ?? [])
->setFormatCache($config['formatCache'] ?? [])
->doResize()
->render();
});
/**
* Publicly accessible URL for permalink image using an identifier/ext.
*/
Route::get('imageresizestatic/{identifier}.{ext}', function (string $identifier, string $ext) {
$perma = ImagePermalink::withIdentifer($identifier);
if ($perma === null) {
$perma = ImagePermalink::defaultNotFound();
}
return $perma->render();
})->where('identifier', '(.+?)');