-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Description
While hacking on some ideas for a future media library (explored over in #71286), I wanted to see whether the post actions we currently have in the editor dataviews would adequately support the attachment
post type.
It turns out that they don't, really. We have at least two actions that aren't applicable to media / attachments:
duplicate-post
— the way it's implemented in Gutenberg, it is expecting to create a new post with content, rather than create a new media itemmove-to-trash
— in most cases, media can't be trashed, so we would probably want to either hide this action, or replace it with permanently delete. Currently the permanently delete action will only work if the post status istrash
, but it should also apply for attachments, I think
A potential solution, would be to hard-code appropriate rules for the attachment
post type within registerPostTypeSchema
as exist for other post types.
Another idea could be to codify this sort of things in add_post_type_support
and access the values from postTypeConfig.supports
. This could be a more declarative way to handle things — however, in the short-term, I wonder if it'd be better to simply hard-code things within the registerPostTypeSchema
function?
Step-by-step reproduction instructions
You can't really test this in Gutenberg right now, so I've thrown up a (very) hacky PR over in #71286 to try to prove out the idea, or at least provide an environment where we can test the different post actions. With that PR applied, you should be able to load up http://localhost:8888/wp-admin/site-editor.php?p=%2Fmedia&layout=table
to view a table layout of media items, and then access the actions in the right hand side.
Duplicate and Move to trash don't work — and (at least in theory) these should be hidden / removed for attachment post types.
Screenshots, screen recording, code snippet
Note: this screenshot is from testing #71286 — the problem described in this issue can't really be replicated in Gutenberg just yet I don't think.

Environment info
No response
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure