[wp-trac] [WordPress Trac] #27028: Custom fields in the Media Uploader added with attachment_fields_to_edit do not behave correctly.
WordPress Trac
noreply at wordpress.org
Fri Oct 3 18:39:57 UTC 2014
#27028: Custom fields in the Media Uploader added with attachment_fields_to_edit do
not behave correctly.
--------------------------+-----------------------------
Reporter: bshewmaker | Owner: wonderboymusic
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.1
Component: Media | Version: 3.9
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
--------------------------+-----------------------------
Changes (by wonderboymusic):
* keywords: reporter-feedback => has-patch
* owner: => wonderboymusic
* focuses: => javascript
* status: new => assigned
* milestone: Awaiting Review => 4.1
Comment:
Gnarly as all of this is, it actually works fine.
[attachment:27028.diff] makes the spinner show up for compat fields.
Here is the PHP code I used to test:
{{{
function ___attachment_fields_to_edit( $form_fields, $post ) {
$flavor = get_post_meta( $post->ID, 'pizza_flavor', true );
$form_fields['pizza'] = array( 'value' => $flavor, 'label' => 'Pizza
Flavor' );
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', '___attachment_fields_to_edit',
10, 2 );
function ___attachment_fields_to_save( $post, $attachment_data ) {
update_post_meta( $post['ID'], 'pizza_flavor',
$attachment_data['pizza'] );
return $post;
}
add_filter( 'attachment_fields_to_save', '___attachment_fields_to_save',
10, 2 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27028#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list