Site Editor: Fix selected featured image when opening media library#59769
Conversation
|
Size Change: +15 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
| // not for site editor. | ||
| wp.media.view.settings.post = { | ||
| ...wp.media.view.settings.post, | ||
| id: postId, |
There was a problem hiding this comment.
postId is a new prop right? I'm thinking that maybe in some flows, the postId is not passed properly to the component and in which case, we may want to keep the globally applied one no?
There was a problem hiding this comment.
Also should we check other <MediaUpload usage in the site editor to check whether we might be missing the postId. For instance uploading regular images while editing a post in the post editor marks the image as attached to the post, but it might not be the case in the site editor. (I'm assuming this latest part is not specific to 6.5 though)
There was a problem hiding this comment.
Makes sense and the complexity in those flows in core is big. I removed the postId for now, since the changes are specific to the featured image flow(unstableFeaturedImageFlow) and the featured image prop is enough for proper selection.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| // not for site editor. | ||
| wp.media.view.settings.post = { | ||
| ...wp.media.view.settings.post, | ||
| featuredImageId: featuredImageId || -1, |
There was a problem hiding this comment.
Now the question, what happens when you open the media library for featured image then you open it for a regular image. do we need to unset this global property? What will be its impact otherwise?
There was a problem hiding this comment.
From what I understood from the code this prop is used for the featured image flow and would not affect anything else. It seems the flow for featured image in wp.media fine tunes some things under the hood, like single selection, confirm button to have set featured image, etc..
|
This is a regression introduced during the 6.5 cycle, so let's include in RC2. |
…59769) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
|
I just manually cherry-picked this PR to the pick/wp-65-rc-2 branch to get it included in the next release |
…59769) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
…ordPress#59769) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
What?
Fixes: #59768
With our unification efforts for site and post editor the featured image panel is reused now in both editors. The featured image panel in site editor results in showing an extra empty thumbnail when opening the media library.
It turns out it all starts with
wp_enqueue_mediawhere in post editor we pass the proper post id, which is responsible for many many things, including setting options for the proper selection too. I don't think that would be the way for site editor as the script loads once and in site editor we update thepostIdwithout reloading.In my approach I update the needed settings when we open the media library modal client side.
Testing Instructions
Before
Screen.Recording.2024-03-12.at.9.46.41.AM.mov
After
after.mov