Skip to content

Media: Rename HEIC companion metadata key to source_image#79307

Merged
adamsilverstein merged 2 commits into
trunkfrom
worktree-update+heic-companion-source-image-key
Jun 18, 2026
Merged

Media: Rename HEIC companion metadata key to source_image#79307
adamsilverstein merged 2 commits into
trunkfrom
worktree-update+heic-companion-source-image-key

Conversation

@adamsilverstein

Copy link
Copy Markdown
Member

What?

Brings back improvements made during the wordpress-develop backport review of the client-side HEIC companion-file handling (WordPress/wordpress-develop#11323).

The headline change: the metadata key that records the sideloaded source-format original (the HEIC kept next to its web-viewable JPEG) was renamed from the generic original to the dedicated source_image. This PR ports that rename to Gutenberg so the plugin and core agree on the key.

Why?

The key name was settled during the core backport review, so Gutenberg has to follow it. If the plugin keeps writing the companion filename under original while core's cleanup reads source_image, the two diverge: the companion file is no longer found on attachment delete and lingers on disk. Keeping the key identical in both places is required for the feature to behave consistently once it ships in core.

The generic original key was also a poor choice on its own - it sits uncomfortably close to the original_image key that the scaled-sideload flow owns. source_image is deliberately specific so the two can never collide.

How?

  • Renames the companion metadata key from original to source_image in Gutenberg_REST_Attachments_Controller::finalize_item().
  • Promotes the size token (original-heic) and the metadata key (source_image) to class constants (IMAGE_SIZE_SOURCE_ORIGINAL, META_KEY_SOURCE_IMAGE) so the /sideload route schema and the metadata writer reference a single source of truth and can't drift apart - mirroring the constants added in the core PR.
  • Aligns the delete_attachment cleanup hook (gutenberg_delete_heic_companion_file()) with the core implementation: it now reads source_image and returns whether a companion file was deleted.
  • Adds PHPUnit coverage for the renamed key and the cleanup hook.

Testing Instructions

  1. On a Chromium 137+ browser with client-side media processing enabled, upload a HEIC image. A JPEG derivative is created and the HEIC is sideloaded alongside it.
  2. Confirm the attachment's metadata records the HEIC filename under source_image (e.g. via wp_get_attachment_metadata() or Query Monitor).
  3. Delete the attachment and confirm the HEIC companion file is removed from the uploads directory.
  4. composer test -- --filter Gutenberg_Delete_HEIC_Companion_File_Test passes.

Related core PR: WordPress/wordpress-develop#11323; original feature PR: #76731.

During the wordpress-develop backport review (WordPress/wordpress-develop#11323),
the metadata key recording the sideloaded source-format original was renamed from
the generic 'original' to the dedicated 'source_image', and the size token and the
key were promoted to controller constants so the sideload schema and the metadata
writer cannot drift apart. Port those changes back so the plugin and core agree on
the key, and align the delete_attachment cleanup hook with the core implementation.

Add PHPUnit coverage for the renamed key and the cleanup hook.
@adamsilverstein adamsilverstein added [Feature] Client Side Media Media processing in the browser with WASM [Type] Enhancement A suggestion for improvement. labels Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Flaky tests detected in c743b90.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27748330360
📝 Reported issues:

@adamsilverstein adamsilverstein merged commit acb09cb into trunk Jun 18, 2026
41 of 42 checks passed
@adamsilverstein adamsilverstein deleted the worktree-update+heic-companion-source-image-key branch June 18, 2026 11:19
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Client Side Media Media processing in the browser with WASM [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants