mindkomm / timmy

Advanced image handling for Timber.
MIT License
171 stars 13 forks source link

Class 'Timmy\Image' not found when using v1.0 #60

Open jeroenbraspenning opened 1 year ago

jeroenbraspenning commented 1 year ago

Today i gave the v1.0 a spin but i get the following error: Fatal error: Uncaught Error: Class 'Timmy\Image' not found in /var/www/html/wp-content/plugins/timmy-1.0.0/lib/Timmy.php:161 Stack trace: #0 /var/www/html/wp-content/themes/yk/template-home.php(10): Timmy\Timmy::get_image(260, 'nocrop') #1 /var/www/html/wp-includes/template-loader.php(106): include('/var/www/html/w...') #2 /var/www/html/wp-blog-header.php(19): require_once('/var/www/html/w...') #3 /var/www/html/index.php(17): require('/var/www/html/w...') #4 {main} thrown in /var/www/html/wp-content/plugins/timmy-1.0.0/lib/Timmy.php on line 161

I installed Timmy as a plugin without composer and initialized Timmy (simplified) as follows:

use Timmy\Timmy;
Timmy::init();
$image = Timmy::get_image(260, 'nocrop');

When taking a look at Timmy.php is see the following:

$class = apply_filters( 'timmy/image/class', Image::class );
$size_array = $size;

if ( is_string( $size ) ) {
if ( in_array( $size, [ 'full', 'original' ], true ) ) {
    $size_array = [];
} else {
    $size_array = Helper::get_image_size( $size );
}
}
$image = $class::build( $attachment, $size_array );

The last line is line 161

Is there anything else i can try to debug this issue?

Timmy version: 1.0 Timber version: 1.22.1

gchtr commented 1 year ago

I’m sorry that I neglected the plugin version a bit.

I think you run into an error where Timmy doesn’t have an autoloader, which is handled through Composer even in the plugin version. But that isn’t loaded correctly yet. I’ll have to fix that.

For now, only the installation through Composer seems to work correctly for 1.x: https://github.com/mindkomm/timmy/blob/1.x/docs/installation.md#install-with-composer.