-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
28 lines (27 loc) · 1.1 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
<?php
Kirby::plugin('jonasfeige/fcs-srcset', [
'fileMethods' => [
'fcsSrcset' => function ($params = []) {
$defaults = [
'width' => 500,
'height' => 350,
'quality' => 90,
'steps' => null,
'breakpoints' => [
['width' => 640, 'ratio' => 1],
['width' => 768, 'ratio' => 1.2],
['width' => 1024, 'ratio' => 1.6],
['width' => 1280, 'ratio' => 2]
]
];
$params = array_merge($defaults, $params);
$steps = $params['steps'] ? $params['steps'] : count($params['breakpoints']);
$set = [];
for ($i = 0; $i < $steps; $i++) {
$image = $this->focusCrop($params['width'] * $params['breakpoints'][$i]['ratio'], $params['height'] * $params['breakpoints'][$i]['ratio'], ['quality' => $params['quality']]);
$set[] = $image->url() . ' ' . $params['breakpoints'][$i]['width'] . 'w';
}
return implode(', ', $set);
}
]
]);