Search code examples
wordpresstwigtimber

Timber "resize" filter won't generate new image sizes


This piece of code (WordPress theme) using the "resize" of Timber filter won't generate the new size image and always returns the source image link instead.

<img src="{{ file.thumbnail.url|resize( 255, 300 ) }}" alt="" class="img-fluid">

No errors are returned, no logs when setting WP_DEBUG to true.


Solution

  • Manually debugging the code in wp-content\plugins\timber-library\lib\Image\Operation\Resize.php, which generates the new images in the run method, shows that function call wp_get_image_editor returns a WP_Error object.

    $image = wp_get_image_editor($load_filename);
    

    Dumping the object gives the reason why it wasn't working:

    No editor could be selected.

    Which means the PHP build installed in the server has no image manipulation extensions. After installing php72-php-gd, the images are generated now.