-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added command to set featured image #57335
base: trunk
Are you sure you want to change the base?
feat: Added command to set featured image #57335
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @singhakanshu00! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @singhakanshu00! Maybe someone with more knowledge at the media upload flow could help more, but here are some first thoughts:
- The command should not be available when a user has no permissions to upload/set a featured image, or a theme has disabled the support for featured images, or a post type doesn't support them(see
PostFeaturedImageCheck
). - I'm not sure how we could use(either reuse or add any missing things) from media utils package. Here is the code for unstableFeaturedImageFlow
- In the current state of this PR, the media library also shows other type of files(audio, etc..), besides images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Alongside what @ntsekouras mentioned, ideally we should not rely on the global state since there are utils which are incorporated into Gutenberg's framework which are used specifically in the set featured image control that this command emulates. The behaviour and implementation should be very similar.
See packages/editor/src/components/post-featured-image/index.js
.
Following that route of implementation will also solve some of the issues above (permissions, media library setup).
What?
Creating a command to set the featured image of the post and pages
Used
useCommand
hook from@wordpress/commands
package to create the command.Why?
Setting featured image using direct command instead of manually following the below steps:
How?
Testing Instructions
Testing Instructions for Keyboard
cmd + k
orctrl + k
to open command palette.Screenshots or screencast
featured-image.mp4