Plugins extending CropEffect don't hash image style URLs

Created on 7 July 2023, over 1 year ago
Updated 30 July 2024, 6 months ago

Problem/Motivation

A plugin that extends CropEffect doesn't have the ?h query parameter added to the URL, so changes are not reflected in a CDN.

Steps to reproduce

Install fresh D9 with image_widget_crop and crop.

1. Create a new crop plugin:


/**
 * Crops an image resource.
 *
 * @ImageEffect(
 *   id = "crop2",
 *   label = @Translation("Alternative crop"),
 *   description = @Translation("Alternatively crop images")
 * )
 */
class CropEffect extends ConfigurableImageEffectBase implements ContainerFactoryPluginInterface {
}

2. Create a new crop type
3. Configure a new image style that uses the "Alternative crop" effect.
4. Add an image field to basic page and configure it to use image_widget_crop
5. Under manage display set the image formatter to the cropped image style.
6. Create a node with an image and set the crops
7. View page

Note that the image URL is missing ?h=

If you change the image effect from "Alternative crop" to "Manual crop" then the ?h is present again.

Proposed resolution

There are some areas in crop that are hard coded to the default "crop_crop" plugin. Having this check something else appears to fix the problem.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia

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

Comments & Activities

Production build 0.71.5 2024