Commit a8cc83c3 authored by Nicolas Widart's avatar Nicolas Widart

Adding default options

parent 636d840d
......@@ -4,7 +4,9 @@ return [
'smallThumb' => [
'crop' => [
'width' => '200',
'height' => '250'
'height' => '250',
'x' => 0,
'y' => 0
],
'blur' => [
'amount' => '15'
......
<?php namespace Modules\Media\Image\Intervention\Manipulations;
use InvalidArgumentException;
use Modules\Media\Image\ImageHandlerInterface;
class Blur implements ImageHandlerInterface
{
private $defaults = [
'amount' => 1
];
/**
* Handle the image manipulation request
* @param \Intervention\Image\Image $image
......@@ -13,9 +16,7 @@ class Blur implements ImageHandlerInterface
*/
public function handle($image, $options)
{
if (!isset($options['amount'])) {
throw new InvalidArgumentException('An amount option is required');
}
$options = array_merge($this->defaults, $options);
return $image->blur($options['amount']);
}
......
<?php namespace Modules\Media\Image\Intervention\Manipulations;
use InvalidArgumentException;
use Modules\Media\Image\ImageHandlerInterface;
class Crop implements ImageHandlerInterface
{
private $defaults = [
'width' => '100',
'height' => '100',
'x' => null,
'y' => null,
];
/**
* Handle the image manipulation request
* @param \Intervention\Image\Image $image
......@@ -13,10 +19,8 @@ class Crop implements ImageHandlerInterface
*/
public function handle($image, $options)
{
if (!isset($options['width']) or !isset($options['height'])) {
throw new InvalidArgumentException('A width and height parameter are required');
}
$options = array_merge($this->defaults, $options);
return $image->crop($options['width'], $options['height']);
return $image->crop($options['width'], $options['height'], $options['x'], $options['y']);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment