Skip to content

[6.x] Ensure images are refreshed properly after cropping#14260

Merged
jasonvarga merged 1 commit into6.xfrom
refresh-cropped-images
Mar 16, 2026
Merged

[6.x] Ensure images are refreshed properly after cropping#14260
jasonvarga merged 1 commit into6.xfrom
refresh-cropped-images

Conversation

@duncanmcclean
Copy link
Member

This pull request fixes an issue where cropped images weren't updating in the asset editor after replacing the original file.

This was happening because the bustAndReloadImageCaches callback had two problems:

  1. Using forEach with an async callback doesn't actually await the operations - the callback returns immediately while fetches happen in the background
  2. Reassigning img.src = url to the same value doesn't reliably trigger a re-fetch since browsers may optimize this as a no-op

This PR fixes it by:

  • Using a for...of loop instead of forEach to properly await each fetch operation
  • Calling removeAttribute('src') before reassigning the src, which forces the browser to re-fetch from the (now updated) HTTP cache

Before

CleanShot.2026-03-16.at.11.12.28.mp4

After

CleanShot.2026-03-16.at.11.11.20.mp4

Fixes #14155

Note: I could only reproduce this issue in Safari - Chrome refreshed images as expected.

@jasonvarga jasonvarga merged commit 03019c1 into 6.x Mar 16, 2026
18 checks passed
@jasonvarga jasonvarga deleted the refresh-cropped-images branch March 16, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image cropping shows old image initially when you replace the original

2 participants