#27761·strapi

Media Library: cropping right after "Replace media" breaks because the cache-busting param is appended to the blob: URL

Author: namnhfreelancerCreated Sep 22, 2026Updated Sep 23, 2026
Labelsissue: bugseverity: mediumsource: core:uploadstatus: pending reproductionversion: 5

Node Version

v24.7.0

Package Manager

Yarn

Package Manager Version

4.17.0

Strapi Version

5.53.0

Operating System

Linux (Debian/Ubuntu)

Database

PostgreSQL

Javascript or Typescript

Typescript

Reproduction URL

No response

Bug Description

In the Media Library edit dialog, cropping an existing (remote) asset right after Replace media — without saving first — shows a broken image and the cropper never starts. Saving the replacement first, reopening the asset and then cropping works fine.

The cause is that the crop-time cache-busting parameter is appended to the local blob: object URL created for the pending replacement file, which produces a blob URL the browser cannot resolve.

Steps to Reproduce

  1. Upload an image to the Media Library.
  2. Open the asset, click Replace media and pick a new image. The preview updates to the new file.
  3. Without saving, click the Crop button.
  4. The preview turns into a broken image, no crop box appears, and the browser reports a failed request for a URL like blob:http://localhost:1337/6f0a…?updatedAt=2026-09-21T09%3A12%3A33.000Z.

Cropping the same asset after saving the replacement works as expected.

Expected Behavior

Cropping a just-replaced (not yet saved) image should work the same as cropping a saved one.

Code Snippets

packages/core/upload/admin/src/components/EditAssetDialog/PreviewBox/PreviewBox.tsx

When a replacement file is selected, the preview URL becomes a local object URL:

typescript
React.useEffect(() => {
  if (replacementFile) {
    const fileLocalUrl = URL.createObjectURL(replacementFile);
    if (asset.isLocal) {
      asset.url = fileLocalUrl;
    }
    setAssetUrl(fileLocalUrl);
    setThumbnailUrl(fileLocalUrl);
  }
}, [replacementFile, asset]);

While cropping, the image is loaded from cropUrl rather than assetUrl:

typescript
const cropUrl = React.useMemo(() => {
  if (!asset.isLocal && !asset.isUrlSigned && assetUrl) {
    return appendSearchParamsToUrl({ url: assetUrl, params: { updatedAt: asset.updatedAt } });
  }
  return assetUrl;
}, [assetUrl, asset.isLocal, asset.isUrlSigned, asset.updatedAt]);

The guard only checks asset.isLocal, which is false for an existing Media Library asset, so the branch also runs when assetUrl is currently the blob: URL of the pending replacement. A blob URL is resolved by exact string match against the browser's blob store, so appending a query string produces a URL that does not resolve:

blob:http://localhost:1337/6f0a-…  ->  blob:http://localhost:1337/6f0a-…?updatedAt=2026-09-21T09%3A12%3A33.000Z

The image fails to load, onLoad never fires, isCropImageReady stays false, and crop() is therefore never called.

Suggested fix — exclude object URLs from the cache-busting branch, since they are local and never cross-origin, so they need no cache busting:

diff
-    if (!asset.isLocal && !asset.isUrlSigned && assetUrl) {
+    if (!asset.isLocal && !asset.isUrlSigned && assetUrl && !assetUrl.startsWith('blob:')) {

Additional information

The code is unchanged on main at the time of writing.

We are running this one-line change as a local patch on 5.53.0; cropping a just-replaced image works again, and cropping a saved remote asset still behaves as before. Happy to open a PR if that helps.

Reported by an editor on Chrome 153 / Windows 11 against a Strapi instance running on Linux.

Confirmation Checklist