Opened 13 years ago
Closed 13 years ago
#22642 closed enhancement (fixed)
Media: API to add back the description field in the new media popup
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.5 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Media | Keywords: | has-patch commit |
| Focuses: | Cc: |
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)
#2
@
13 years ago
- 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.
#3
@
13 years ago
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.
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 );