Repository navigation
Keep DAM transformations and overlays when recreating a delivery relation - #1352
Merged
Merged
Conversation
…livery relation An asset inserted from the DAM with a crop or effects stages those transformations in post meta until it gets a delivery relation. create_size_relation() moves them into the new row and deletes the post meta, but create_delivery() then restored the transformations it had captured before the row existed (none). The restore goes through a relationship save deferred to shutdown, so it overwrote the migrated value with null and the transformations were lost for good. The capture also came from Relate::get_transformations(), which is memoized per request, so recreating the relation again in the same request kept capturing the stale value. Recreating an existing relation also baked its overlays into the transformations column, as the capture merged them in, and dropped the overlay columns. Capture the transformations and overlays from the relationship data instead, each in its own column, and write them with the new relation itself rather than restoring them afterwards. Transformations staged in post meta still take precedence.
utkarshcloudinary
approved these changes
Nov 2, 2026
utkarshcloudinary
left a comment
Collaborator
There was a problem hiding this comment.
looks good! ✅
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.
Fixes transformations (crops and effects) applied in the DAM widget being lost for good when the asset is inserted into WordPress.
The issue
An asset inserted from the DAM with transformations stages them in post meta until it gets a delivery relation.
Delivery::create_size_relation()moves them into the new relationship row, and deletes the post meta.Delivery::create_delivery()then restored the transformations it had captured before the row existed, which was nothing.That restore goes through a relationship save that runs on shutdown, so it overwrote the migrated value with
null.With the post meta already deleted, the transformations couldn't be recovered without re-importing the asset.
Recreating an existing relation had a related issue: the capture merged the text and image overlays into the transformations string. The overlay columns were then dropped and the overlays ended up in
transformations.The solution
create_delivery()now readstransformations,text_overlayandimage_overlayfrom the relationship data, each kept in its own column.create_size_relation()through a new optional$preserveargument and written with the new row, instead of being restored afterwards. Transformations staged in post meta still take precedence. The other caller (class-assets.php) is unchanged.tests/phpunit/tests/test-delivery-create-delivery.php. All 4 tests fail ondevelopand pass on this branch.QA notes
Prerequisites
Steps:
develop: the image loses the transformations.Notes: to compare
developand this branch: go through all the steps on each branch, as the transformation is lost before the block sidebar changes. That setting change just helps confirm it.