Opened 7 weeks ago
Closed 9 days ago
#65987 closed enhancement (fixed)
Media Editor Modal: track the original attachment id for edited images
| Reported by: | ramonopoly | Owned by: | peterwilsoncc |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Media | Version: | trunk |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
This ticket tracks the work for the following issue:
Media: Tracking the relationship between original images and their cropped derivatives
And PR:
Media: track the original attachment id for edited images- #81803
When Gutenberg crops an image, Core's /edit creates an entirely new attachment with no stable pointer back to the image the lineage started from.
parent_image records only the immediate source; there is no root/original reference across crop-of-crop chains.
That means we can't navigate a crop back to its original in a performant way, that is, without getting each post up the change where parent_image exists.
Media: track the original attachment id for edited images- #81803 proposes to add a dedicated postmeta key _wp_attachment_original_id stores the root id.
There's no conflict with the current "restore image" functionality in the media library, which is file-based.
Change History (5)
This ticket was mentioned in PR #13303 on WordPress/wordpress-develop by @ramonopoly.
7 weeks ago
#2
- Keywords has-patch has-unit-tests added
@ramonopoly commented on PR #13303:
13 days ago
#3
One other question I had, and I don't think it's a blocker for this PR but would be good to consider, is what should happen for importers / WXR exports.
Thanks for flagging this! I had a bit of a dig around and found something else that looks interesting:
_thumbnail_id is collected during post meta import and rewritten to the new ids afterwards in remap_featured_images().
So maybe a follow up to the simpler, skipping could be to remap in a similar way. I think your idea of skipping is probably the best, first version: it'll avoid bad relationships after import, e.g., if an attachment with the same id already exists
@ramonopoly commented on PR #13303:
13 days ago
#4
I think your idea of skipping is probably the best, first version: it'll avoid bad relationships after import, e.g., if an attachment with the same id already exists
Draft PR here when/if we need it:
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
## What? Why?
When Gutenberg crops an image, Core's /edit creates an entirely new attachment with no stable pointer back to the image the lineage started from.
parent_imagerecords only the immediate source; there is no root/original reference across crop-of-crop chains.That means we can't navigate a crop back to its original in a performant way, that is, without getting each post up the change where
parent_imageexists.This PR adds
original_attachmentmetadata undermedia_detailsto track the lineage.Trac ticket: https://core.trac.wordpress.org/ticket/65987
## Use of AI Tools
To create the backport of https://github.com/WordPress/gutenberg/pull/81803 and its tests