Opened 11 years ago
Closed 9 years ago
#23932 closed enhancement (fixed)
Support for remove_post_type_support() in attachment post type
Reported by: | flyingtrolleycars | Owned by: | antpb |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 3.5.1 |
Component: | Media | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
In the past it was possible to remove certain fields from the media editor by hooking "attachment_fields_to_edit" and unset'ing the fields you didn't want included (e.g. caption).
After the media library got the major rework in WP3.5 its longer possible to remove those fields.
I believe that since the attachment post type has been more closely lined up to normal posts it should support remove_post_type_support() et al.
The easiest (and probably popular) case for this is removing the editor. I believe this code should do the trick:
remove_post_type_support( 'attachment', 'editor' );
Attachments (7)
Change History (23)
#2
@
10 years ago
- Keywords needs-patch added
Caption
maps to post_excerpt
, Description
maps to post_content
, the remove_post_type_support()
calls should respect that.
remove_post_type_support( 'attachment', 'title' )
works properly for the Edit Media screen, but not in the modal.
Alt text is saved as post meta under the _wp_attachment_image_alt
key, so that can't be disabled via the same mechanism.
Needs patch.
#3
@
10 years ago
- Keywords good-first-bug added
- Owner set to antpb
- Status changed from new to assigned
#4
follow-up:
↓ 5
@
10 years ago
In posts.php the array was not registering 'caption'
for global $_wp_post_type_features;
This includes caption into the array
'supports' => array( 'title', 'author', 'comments', 'caption' ),
The media panel is not determining to show it based on the array. Continuing to look into where that is linked.
#5
in reply to:
↑ 4
@
10 years ago
Fun pair programming at #wcsf14. @antpb will push it over the line!
#6
@
10 years ago
- Keywords has-patch dev-feedback needs-unit-tests added; needs-patch removed
First pass. Worked with Solvitor on this one so please share the credit!
We added 'alt' 'description' and 'caption' to the array that links up.
#8
@
10 years ago
Noticed that the embed edit image panel was overlooked and revised media-template.php to omit captions and alt text if defined with remove_post_type_support
Adding updated patch.
#11
follow-up:
↓ 12
@
10 years ago
- Keywords needs-patch added; has-patch dev-feedback needs-unit-tests removed
There is code in the theme that shouldn't be in the patch.
#12
in reply to:
↑ 11
@
10 years ago
Replying to wonderboymusic:
There is code in the theme that shouldn't be in the patch.
Removed theme code from patch. Here's the update.
#14
@
9 years ago
As per Nacin's suggestion I have removed all of the post supports except title as it is the only one that is already registered as reported and may have the need to be removed. I have tested this and it seems to be working fine when adding the removal of the title post type and also without the removal.
#15
@
9 years ago
- Milestone changed from Awaiting Review to 4.3
It doesn't look like there is much of a demand for this, so I suggested to @antpb that we simply fix this for 'title', since it's an existing supports argument.
Adding new 'supports' arguments is a bit tenuous, and has gotten us to consider things like a separate 'disables' flag. (This came up with #21391 and elsewhere, but hasn't had a real need yet.)
In this case, I don't see a major reason to disable other fields, though. And if you needed to, you could still hide or remove them via JS or PHP. There's also the old disable_captions filter we kept around after 3.5.
Committing 23932-6.patch.
I'd love to see this. I'd think that removing support for "caption", for example, would remove the caption field both from the media modal and also the edit media screen.