[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
Wed Feb 5 22:56:57 UTC 2014


#27028: Custom fields in the Media Uploader added with attachment_fields_to_edit do
not behave correctly.
--------------------------+-----------------------------
 Reporter:  bshewmaker    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 While trying to add a custom 'credit' field to the Media Uploader
 attachment fields, I used add_filter( 'attachment_fields_to_edit',
 function( $form_fields, $post ) to create the field and then add_filter(
 'attachment_fields_to_save', function( $post, $attachment ) and
 update_post_meta to save the value of the field.  This field does not
 behave the same as the default fields (title, caption, alt text,
 description) in the media uploader.  Normally, when clicking from one
 field to the next, a background call is made which saves that information
 in the background while at the same time a waiting animation appears in
 the upper right hand corner of the media uploader modal to indicate to the
 user that something is processing.  However, when clicking away from my
 custom credit field added with 'attachment_fields_to_edit', this animation
 does not appear.  In addition, when the background saving is finished, the
 cursor moves back to the custom field, even if the user is typing
 something in a different field.

 For example, say you typed 'photo by Bob' in the custom credit field.
 Then you click away from the field and start typing a description in the
 'Description' field.  Even if you do not make another mouse click and are
 typing in that field, when the background call to admin-ajax.php is
 finished, the cursor is re-focused on the custom field and the entire text
 there is highlighted so that if you were in the middle of typing you might
 end up over-riding the text that was previously in the credit field.  This
 behavior does not happen with the default fields, only fields added with
 the add_filter('attachment_fields_to_edit').

 I am not familiar with Backbone.js and I am not sure if the issue is
 because the HTML generated from attachment_fields_to_edit is not working
 correctly with the Media Uploader js code, or perhaps something in the
 media js code is not playing nice with the HTML or vice versa or something
 else entirely.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27028>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list