laravel-mediable icon indicating copy to clipboard operation
laravel-mediable copied to clipboard

ImageManipulator::defineVariant should not be called staticallyNon static method 'defineVariant' should not be called

Open khanakia opened this issue 1 year ago • 4 comments

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()
        );

Screenshot 2024-08-25 at 9 27 30 PM

khanakia avatar Aug 25 '24 15:08 khanakia

I am getting the same issue. plus i am getting:

Call to undefined method Intervention\Image\Image::fit()

Any solution?

wisammways avatar Dec 15 '24 18:12 wisammways

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 avatar Dec 18 '24 20:12 EriBloo

@EriBloo Thank you It fixed the fit() issue.

wisammways avatar Jan 21 '25 21:01 wisammways

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() ); Screenshot 2024-08-25 at 9 27 30 PM

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.

Stephan-MC avatar Mar 14 '25 13:03 Stephan-MC