Skip to content

[Bug]: Folder preview thumbnails permanently show loading spinner for newly uploaded assets Module #1105

@Refaat-alktifan

Description

@Refaat-alktifan

Version

2.3.2 (also affects 2.2.x, 2.3.0, 2.3.1)

Description

When uploading images to an asset folder and viewing them in the Preview tab, thumbnails that haven't been generated yet show a loading spinner (video-loading.gif) that never resolves, even after the thumbnail has been generated by the messenger worker. The spinner persists until the user does a hard browser refresh (Ctrl+F5) or switches to the List view.

Root Cause

Two issues in AssetController::getImageThumbnailAction() at line 1179-1181:

1. Placeholder response is cacheable

When origin=folderPreview and the thumbnail doesn't exist yet, the controller returns video-loading.gif as a BinaryFileResponse without Cache-Control: no-store headers. The browser caches this response.

The getFolderContentPreviewAction generates thumbnail URLs using the asset's modificationDate as the _dc cache-buster parameter (e.g. _dc=1774887063). Since this timestamp never changes for the same asset, subsequent requests hit the browser cache and serve the cached spinner forever.

2. No async thumbnail generation is dispatched

For origin=treeNode, the controller dispatches AssetPreviewImageMessage to trigger async thumbnail generation. But for origin=folderPreview, no message is dispatched — the thumbnail is only generated if/when the pimcore_asset_update worker processes it independently.

Steps to Reproduce

  1. Open the Pimcore admin UI
  2. Create a new asset folder
  3. Upload 5-6 images (e.g. JPEG, 3-600KB each)
  4. Open the folder → click Preview tab
  5. Observe: some images show the loading spinner, others may show correctly (depends on timing)
  6. Wait 30+ seconds (worker generates thumbnails)
  7. Reload the page → spinners persist
  8. Switch to List view → all thumbnails display correctly

Why List view works

The List view uses a different URL pattern:

/admin/asset/get-image-thumbnail?id=1429852&treepreview=1&width=108&height=70&frame=1

The Preview (folder) view uses:

/admin/asset/get-image-thumbnail?id=1429852&treepreview=1&_dc=1774887063&origin=folderPreview

Different URL = no cached stale response in the browser.

Current code

https://github.com/pimcore/admin-ui-classic-bundle/blob/2.3/src/Controller/Admin/Asset/AssetController.php#L1169-L1183

Proposed fix

} elseif ($request->get('origin') === 'folderPreview') {
    \Pimcore::getContainer()->get('messenger.bus.pimcore-core')->dispatch(
        new AssetPreviewImageMessage($image->getId())
    );
    $response = new BinaryFileResponse(PIMCORE_WEB_ROOT . '/bundles/pimcoreadmin/img/video-loading.gif');
    $response->headers->set('Cache-Control', 'no-store, must-revalidate');
    $response->headers->set('Pragma', 'no-cache');
    $response->headers->set('Expires', '0');
    return $response;
}

Changes:

  1. Dispatch AssetPreviewImageMessage : triggers async thumbnail generation (same behavior as treeNode)
  2. Set Cache-Control: no-store : prevents the browser from caching the placeholder spinner, so the next request hits the server and gets the real thumbnail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions