@@ 5-27 (lines=23) @@ | ||
2 | ||
3 | use Modules\Media\Image\ImageHandlerInterface; |
|
4 | ||
5 | class Fit implements ImageHandlerInterface |
|
6 | { |
|
7 | private $defaults = [ |
|
8 | 'width' => 100, |
|
9 | 'height' => null, |
|
10 | 'position' => 'center', |
|
11 | ]; |
|
12 | ||
13 | /** |
|
14 | * Handle the image manipulation request |
|
15 | * @param \Intervention\Image\Image $image |
|
16 | * @param array $options |
|
17 | * @return \Intervention\Image\Image |
|
18 | */ |
|
19 | public function handle($image, $options) |
|
20 | { |
|
21 | $options = array_merge($this->defaults, $options); |
|
22 | ||
23 | $callback = isset($options['callback']) ? $options['callback'] : null; |
|
24 | ||
25 | return $image->fit($options['width'], $options['height'], $callback, $options['position']); |
|
26 | } |
|
27 | } |
|
28 |
@@ 5-26 (lines=22) @@ | ||
2 | ||
3 | use Modules\Media\Image\ImageHandlerInterface; |
|
4 | ||
5 | class Resize implements ImageHandlerInterface |
|
6 | { |
|
7 | private $defaults = [ |
|
8 | 'width' => 200, |
|
9 | 'height' => 200, |
|
10 | ]; |
|
11 | ||
12 | /** |
|
13 | * Handle the image manipulation request |
|
14 | * @param \Intervention\Image\Image $image |
|
15 | * @param array $options |
|
16 | * @return \Intervention\Image\Image |
|
17 | */ |
|
18 | public function handle($image, $options) |
|
19 | { |
|
20 | $options = array_merge($this->defaults, $options); |
|
21 | ||
22 | $callback = isset($options['callback']) ? $options['callback'] : null; |
|
23 | ||
24 | return $image->resize($options['width'], $options['height'], $callback); |
|
25 | } |
|
26 | } |
|
27 |