Block Editor: stabilize editMedia setting for image crop#76628
Closed
Block Editor: stabilize editMedia setting for image crop#76628
Conversation
|
Size Change: +13 B (0%) Total Size: 8.75 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 1deb90f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23242853296
|
Member
Author
|
Closing this for now until we stabilize the media editing flow. See conversation in: #76626 (review) |
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.
Problem
Note
This needs some thought. Is adding a public setting to the block-editor the right path? Is there an existing or better model for media operations?
Alternative and/or follow up to:
The image crop/rotate feature in the Image and Site Logo blocks relied on a private Symbol key (
mediaEditKey) to pass the save callback through block editor settings. This had two consequences:Solution
Replace the private Symbol with a public
editMediasetting onBlockEditorProvider. Its presence gates the crop UI — no callback, no button — and its value is the function called when the user applies a crop or rotation.In the standard WordPress editor,
@wordpress/editorwires this up automatically usingeditMediaEntityfrom@wordpress/core-datawhen the current user has upload permissions. Custom block editors can supply their own implementation:If
editMediais not provided, the crop/rotate toolbar is hidden entirely. Custom block editors that don't support media editing get correct behaviour without any extra configuration.Changes
mediaEditKeySymbol fromblock-editorprivate APIseditMediaas a documented public setting (seepackages/block-editor/README.md)@wordpress/editorsetseditMediatoeditMediaEntitywhen the user has upload permissionscanEditImageon!! editMediaTesting
Setup: add this to a must-use plugin to strip upload permissions from the Author role: