Image style derivative flush missing on update

Created on 22 September 2017, over 7 years ago
Updated 3 August 2023, over 1 year 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 over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year 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.71.5 2024