Opened 6 months ago
Closed 6 months ago
#22642 closed enhancement (fixed)
Media: API to add back the description field in the new media popup
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | batmoo |
Description
Description was dropped as a field in the media popup. Would be nice to have a allow plugins to re-add the field.
Attachments (3)
Change History (10)
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.5
On why the unset() calls are there: get_attachment_fields_to_edit() returns all of those fields: align, caption, size choices, etc. But because it returns all of those fields, it is very slow. (In particular, image_downsize() is slow. See #22598 for how we work around that.) So instead, we just apply the raw filter.
I kept the unset() calls because it is possible that a plugin could be re-defining some of those fields in a bad way (rather than just appending to the array), and we wouldn't want that, as we already handle those fields in newer, better ways.
The exception is Description (post_content). We don't handle it, but it was something get_attachment_fields_to_edit() previously returned. Stop unsetting it, and now a plugin can add it back with just a few lines of code.
Second patch tosses in a save handler for free. Since it used to be a default field, I figure we can just continue to account for it in core.
Patch and code snippet work nicely for the media popup but duplicates the description field on the "Edit Media" screen.

With the patch:
add_filter( 'attachment_fields_to_edit', function( $fields, $post ) { $fields['post_content'] = array( 'label' => __('Description'), 'value' => $post->post_content, 'input' => 'textarea' ); return $fields; }, 10, 2 );