ImageManipulator::defineVariant should not be called staticallyNon static method 'defineVariant' should not be called
Getting the error
Version: "plank/laravel-mediable": "^5.9.1"
defined in boot func in app/Providers/AppServiceProvider.php
ImageManipulator::defineVariant(
'thumb',
ImageManipulation::make(function (Image $image, Media $originalMedia) {
$image->fit(300, 300);
})->outputWebpFormat()
);
I am getting the same issue. plus i am getting:
Call to undefined method Intervention\Image\Image::fit()
Any solution?
Hi. @wisammways are you using laravel-mediable 6 with intervention/image 3? If so they changed fit and some other methods in this version:
The resizing methods resize(), fit(), widen() and heighten() have been completely rebuild and are now handled by resize(), resizeDown, scale(), scaleDown(), cover(), coverDown(), pad() and contain()
Check upgrade guide
@EriBloo Thank you It fixed the fit() issue.
Getting the error
Version:
"plank/laravel-mediable": "^5.9.1"defined in boot func in
app/Providers/AppServiceProvider.phpImageManipulator::defineVariant( 'thumb', ImageManipulation::make(function (Image $image, Media $originalMedia) { $image->fit(300, 300); })->outputWebpFormat() );
as a solution to the initial problem, The main issue is found in the docBlock of the ImageManipulation class. The defineVariant method is well defined but the php linter had issues with a typo in the docBlock.
the docBlock
/**
* @method static defineVariant(string $variantName, ImageManipulation $manipulation)
* ...
*/
has to be changed to
/**
* @method static void defineVariant(string $variantName, ImageManipulation $manipulation)
* ...
*/
the void keyword was omitted.