-
Notifications
You must be signed in to change notification settings - Fork 2.8k
V16: Replacing media files does not update the preview #19912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V16: Replacing media files does not update the preview #19912
Conversation
…ernal store optional, and deprecates an old method
…e consumed before proceeding
…updated or deleted
…as already been loaded once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where replacing media files doesn't update the preview by implementing event-driven thumbnail updates and comprehensive cache management. The changes ensure that image thumbnails are automatically refreshed when media items are updated.
- Introduces automatic thumbnail refresh when media items are updated via event listeners
- Adds cache clearing functionality to the imaging repository and store
- Deprecates the old
requestThumbnailUrls
method in favor of the more flexiblerequestResizedItems
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
media-detail.repository.ts | Adds cache clearing after save/delete operations |
media-grid-collection-view.element.ts | Fixes property binding and import ordering |
imaging.store.ts | Adds cache management methods and improves type safety |
imaging.repository.ts | Enhances API with async initialization and cache clearing methods |
imaging-thumbnail.element.ts | Implements event-driven thumbnail refresh and updates rendering logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/imaging-thumbnail.element.ts
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/imaging-thumbnail.element.ts
Show resolved
Hide resolved
…media-files-does-not-update-the-preview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything works as expected 🥳
Would it be ok with you if we leave the caching part out of this PR? I would like to align it with the detail and item caching instead.
Description
Fixes #19830
This pull request introduces several improvements to the media imaging system, focusing on cache management, event-driven thumbnail updates, and API enhancements. The changes ensure that image thumbnails are refreshed when media items are updated, and that the cache is properly cleared after media modifications. Additionally, the imaging repository and store APIs have been expanded to support more flexible cache operations and improved type safety.
Event-driven thumbnail refresh and cache management:
umb-imaging-thumbnail
component now listens for media update events and refreshes its thumbnail automatically when the corresponding media item is updated. This ensures that users always see the latest image without manual refresh. [1] [2]UmbMediaDetailRepository
now clears the image cache for a media item whenever it is saved or deleted, preventing stale thumbnails after media changes.Imaging repository and store API enhancements:
UmbImagingRepository
class now supports asynchronous initialization, optional data store usage, and new methods for clearing the cache globally or by unique identifier. TherequestThumbnailUrls
method is now deprecated in favor ofrequestResizedItems
, which provides more flexibility. [1] [2] [3]UmbImagingStore
class now offers methods to clear all crops, clear crops by unique identifier, and clear crops by configuration, improving cache control and maintainability. Type annotations have been added for better type safety. [1] [2] [3]Code quality and usage improvements:
These updates collectively enhance the reliability and flexibility of media thumbnail management in the application.
How to test