Using ImageEffect "image_convert" from core can break h-parameter

Created on 6 August 2021, over 3 years ago
Updated 4 September 2024, 3 months ago

Problem/Motivation

If you use ImageEffect "image_convert" from core, the image derivative file URI changes and the crop can no longer be found in the crop_field_data table. Therefore the h-parameter is no longer applied and the image derivative is not updated (cached).

How I found this:

  • The h-parameter is applied in crop.module line 164 function crop_file_url_alter.
  • The $uri variable contains something like 'image.jpg.png'. The original image file name is 'image.jpg'.
  • This calls Crop::getCropFromImageStyleId
  • Which calls findCrop
  • Which calls \Drupal::entityTypeManager()->getStorage('crop')->getCrop($uri, $type);
  • Which queries the crop_field_data table with the $uri variable -> $query = $this->database->select('crop_field_data', 'cfd');

Steps to reproduce

  • Install Drupal, crop and focal_point crop.
  • Add an image style that converts to PNG and uses focal_point crop.
  • Add an image field to a content type.
  • Configure the view mode to use the image style.
  • Add a node of the content type and and a JPG image. Set a focal point.
  • View the page.
  • Edit the page, select another focal point and save.
  • View the page again, the focal point change is not reflected.

Proposed resolution

?

Remaining tasks

?

User interface changes

?

API changes

?

Data model changes

?

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇧🇪Belgium stefdewa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024