Problem/Motivation

Now that Drupal 8 is approaching end of life I really need to upgrade to Drupal 9. Crop API as one of the two modules preventing me from doing this. I am currently using Crop API 1.2 which works fine with Drupal 8.9.19. However when I upgrade to 2.1 (or 1.5) images crops are not being regenerated after being flushed or created for new users.

Steps to reproduce

On Crop API 1.2:

Goto Configuration | Media | Image styles and flush an image style that is correctly cropping images and showing them on the site. Then visit a page showing a cropped image of this style and refresh the page. The image is correctly regenerated.

Doing the same with Crop API 2.1 does not regenerate the image.

Please can someone suggest what I can do to correct this? Thanks for any help!

Comments

DarkstarTom created an issue.

philipp jor’s picture

I have the Same Problem in Drupal 8.9.1 after updating from Drupal 8.7
Using php7.2
-> In Drupal 8.7 -> Crop API 8.x-2.2 works
-> In Drupal 8.9.1 -> Crop API 8.x-2.2 does not work

Did you find a way to solve the problem?

I get this error-message by using a form with the cropping-funktion:

The file "public://filename.jpg" is not valid on element field_imagename[0][image_crop].

nathan tsai’s picture

For some reason, I'm also getting this issue.

The cropping is not being applied for the image styles, even after flushing the caches.

darkstartom’s picture

I found a workaround. The problem is that the crop module adds unnecessary "&" characters to the URL of a cropped image, this can be corrected using a TWIG replace filter eg:

<img src="{{ image_filename|replace({'&amp;' : '&'}) }}">

Just be careful that the filenames don't contain the "&" character!

szeidler’s picture

I also notice the problem. For me it happens only if we're not using the typical Drupal render pipeline, but rather have a custom TWIG like the following, similar like comment #5

<img src="{{ src }}">

With the regular <img{{ attributes }} /> it just works fine.

It's TWIG magic I would guess, because if you pass the raw value like <img src="{{ src | raw }}">, you will also not encounter an encoding.