0

I'm migrating a site to a new host. On the front end, I see...

Twig_Error_Syntax: Unknown "image_style" filter. in Twig_ExpressionParser->getFilterNodeClass() (line 57 of /var/www/prod/web/themes/mytheme/templates/paragraph--paragraph_image_block.html.twig).

However, I checked the filter referenced in the error, and the filter is not missing. I see the filter at admin/config/media/image-styles and its machine name is spelled correctly in the template. I have tried rebuilding the cache. Why is this filter unknown?

Here is line 57 in the template:

{% set img_url = file_url(content.field_paragraph_image['#items'].entity.uri.value | image_style('max_1300x1300')) %}

The 'max_1300x1300' filter isn't missing.

1
  • 2
    The error isn't about whether you have defined an image style or not with that machine name, the error is telling you there is no Twig filter by that name. Two different things.
    – Kevin
    Mar 1 '19 at 19:08
5

The error message isn't complaining about a missing Drupal image style - it's complaining about a missing Twig filter named image_style.

That filter doesn't exist in Twig/Drupal core, but it does exist in the Twig Tweak module. Make sure that module is available and installed, and the error should disappear.

If you've never had Twig Tweak installed then it's probably custom. In that case search your codebase for Twig_SimpleFilter('image_style' and you should find the culprit.

1
  • Yep. The twig_tweak module was not enabled.
    – arnoldbird
    Mar 1 '19 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.