-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
Thank you for your work. This is my favorite admin panel for Laravel. On the last project I noticed that $form->image() uses the second version of Intervention Image. I suggest a fix for switching to the third Intervention Image version in the file \src\Form\Field\Traits\ImageField.php:
namespace OpenAdmin\Admin\Form\Field\Traits;
use Illuminate\Support\Str;
use Intervention\Image\Constraint;
use Intervention\Image\Facades\Image as InterventionImage;
use Intervention\Image\ImageManagerStatic;
// Use class
use Intervention\Image\ImageManager;
use Symfony\Component\HttpFoundation\File\UploadedFile;
...
public function callInterventionMethods($target)
{
if (!empty($this->interventionCalls)) {
// Add condition
if(!class_exists(ImageManager::class)) {
$image = ImageManagerStatic::make($target);
} else {
$driver = config("image.driver");
$manager = new ImageManager(new $driver());
$image = $manager->read($target);
}
foreach ($this->interventionCalls as $call) {
call_user_func_array(
[$image, $call['method']],
$call['arguments']
)->save($target);
}
}
return $target;
}
...
public function __call($method, $arguments)
{
if (static::hasMacro($method)) {
return $this;
}
// Change condition
if (!class_exists(ImageManagerStatic::class) && !class_exists(ImageManager::class)) {
throw new \Exception('To use image handling and manipulation, please install [intervention/image] first.');
}
$this->interventionCalls[] = [
'method' => $method,
'arguments' => $arguments,
];
return $this;
}
As far as I can tell, the methods in version 3 are the same.
Metadata
Metadata
Assignees
Labels
No labels