feat: replace asset option for image assets in asset details#5676
Merged
kof merged 15 commits intowebstudio-is:mainfrom Apr 10, 2026
Merged
feat: replace asset option for image assets in asset details#5676kof merged 15 commits intowebstudio-is:mainfrom
kof merged 15 commits intowebstudio-is:mainfrom
Conversation
Add a 'Replace Asset' button (RefreshIcon) next to the download button in the asset details popover. This is only shown for image-type assets. When triggered, the user selects a new image file which is uploaded via the existing pipeline. All references to the original asset (props, styles, page meta) are atomically re-pointed to the new asset in a single transaction. The original asset's filename and description (alt text) are preserved on the replacement. The old asset is then deleted. - New module: replace-asset.ts with replaceAsset() function - Updated asset exports in index.ts - Modified asset-info.tsx to render replace button (disabled in view mode)
Add a new ReverseIcon and use it for the asset replace action in the builder UI.
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
reviewed
Apr 7, 2026
kof
requested changes
Apr 7, 2026
Use $assets.subscribe() instead of a setTimeout loop so waitForAsset resolves as soon as the upload completes, regardless of network speed. Removes the arbitrary 60s timeout and 500ms polling interval.
Props with type "asset" hold an asset ID reference and can not represent width or height, which are always type "number" per the schema. The name checks were dead code.
Contributor
Author
|
@kof resolved all the items mentioned in the review |
|
🚀 Deployed! 📍 Preview: https://pr-5676.development.webstudio.is Note: Adding new commits will remove the |
Member
|
Found a bug after testing:
If I reload and do step 6 again - it will work. |
$assets.subscribe() fires its callback synchronously, causing a "Cannot access 't' before initialization" ReferenceError when the asset already exists in the store (e.g. after undo → delete → re-replace). Check current value with .get() first for an early return, and use .listen() instead of .subscribe() to avoid the synchronous callback.
Contributor
Author
|
@kof good catch! This was a TDZ bug in fixed in the latest commit. |
Member
|
merged 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the ability to replace an existing image asset with a new file directly from the asset details panel, without having to delete and re-upload manually. Related to place an image so that it gets replaced automatically everywhere its being used #3268
When clicking the new replace button on an image asset:
A new
ReverseIconfrom the Figma library was added to the icons package to represent the replace action.Steps for reproduction
Code Review
Before requesting a review
Before merging
.envfile