HashandSalt / kirby3-webp

A WebP helper for Kirby 3
MIT License
33 stars 1 forks source link

Missing Class "Stack" #2

Closed S1SYPHOS closed 4 years ago

S1SYPHOS commented 4 years ago

Hey there, I get an error when using your fantastic lib, and it's fixed when I use WebPConvert\Convert\Converters\Stack; in the main index.php

Cheers! S1SYPHOS

HashandSalt commented 4 years ago

Thanks for raising it. However, would you mind telling how you managed to trigger that error? I have used this on quite a few projects and never seen that one.

S1SYPHOS commented 4 years ago

I called the snippet through a file method. The file method resides in a plugin folder and is included by that plugin folder's index.php with 'fileMethods' => require_once 'file.php'

HashandSalt commented 4 years ago

Hrmm... but what i dont understand is that line is inside a files that included into the top of index.php should work without that.

HashandSalt commented 4 years ago

But maybe your file method cant see it becuase it's outside my plugin?

HashandSalt commented 4 years ago

@S1SYPHOS The plugin does have a bunch of filemethods built in. The ->toWebp() will convert an image to webp on the fly in template if you already had images on the site before installing plugin.

https://github.com/HashandSalt/kirby3-webp/blob/master/index.php#L42

S1SYPHOS commented 4 years ago

This method seems only available in some places, too ..

I gotta investigate further. Totally weird and first time something like this happened!

S1SYPHOS commented 4 years ago

.. but I seem to be the only one having this problem so far, right?

HashandSalt commented 4 years ago

@S1SYPHOS Actually somone else raised it with me yesterday. My hunch is that its a PHP 7.4 issue. Ive certainly not seen it with 7.2 or 7.3. That library is loaded in the file that is included at the top of the index PHP file, so its really odd that it cant see it.

HashandSalt commented 4 years ago

Maybe 7.4 is stricter in the way that dependencies are included. I dont know.

S1SYPHOS commented 4 years ago

Am I right to assume that it certainly doesn't hurt to include it, then :B ?

psntr commented 4 years ago

Thanks @S1SYPHOS!, I had the same issue, and fix it by adding use WebPConvert\Convert\Converters\Stack;, would be nice to have it in the next release

S1SYPHOS commented 4 years ago

@HashandSalt should I open a PR then or .. ;)

HashandSalt commented 4 years ago

Should be fixed now.