Image style derivative flush missing on update

Created on 22 September 2017, almost 7 years ago
Updated 3 August 2023, 11 months ago

Problem/Motivation

After updating crop settings for an image, the image style derivatives that were generated with previous crop settings aren't being flushed from disk. This causes the server to serve old files, despite the hash and itok change for the image URL, because the files are still there and haven't been modified.

Proposed resolution

Use the same approach for flushing styles using imageStylesOperations method of ImageWidgetCropManager class.

Remaining tasks

Review and evaluate the patch.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡²πŸ‡©Moldova Spurlos Chisinau

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.

  • πŸ‡¨πŸ‡¦Canada Nathan Tsai

    #14 has worked for me for more than 2 years and #17 only updates a word in the log request.

    I think it's safe to say it's reviewed & tested by the community.

  • Status changed to Needs review 11 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 11 months ago
    4 pass
  • πŸ‡¨πŸ‡¦Canada Nathan Tsai

    I encountered an issue where the derivative would not generate until the cropping was applied twice.

    E.g. only when the status message of The crop "@cropType" was successfully updated for image "@filename". was shown.

    I then learned that the function(ImageWidgetCropManager::imageStylesOperations) doesn't apply to the code path on the first save.

    After applying, the derivatives are now generated on the first save.

  • πŸ‡¨πŸ‡¦Canada Nathan Tsai

    Note: these are the modules I have applied that requires #19.

        "require": {
            "drupal/crop": "^2.2",
            "drupal/exif_orientation": "^1.1",
            "drupal/filefield_sources": "^1.0@alpha",
            "drupal/filename_transliteration": "^1.1",
            "drupal/image_widget_crop": "^2.4",
            "drupal/simple_image_rotate": "^2.1.1",
            "drupal/webp": "^1.0@beta",
        },
        "extra": {
            "patches": {
                "enable-patching": true,
                "drupal/webp": {
                    "#3186383: Fix image regeneration for duplicate filenames with different casing": "https://www.drupal.org/files/issues/2022-02-02/webp_access_denied-3186383-11.patch",
                    "#3153137: Fix regenerate images after crop": "https://www.drupal.org/files/issues/2022-10-31/webp-support-image-crop-3153137-34.patch"
                },
                "drupal/image_widget_crop": {
                    "#2910886: Update the save": "https://www.drupal.org/files/issues/2022-11-18/image_style_derivative-2910886-17.patch"
                }
            }
        },
    
Production build 0.69.0 2024