Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#27029 closed defect (bug) (duplicate)

Custom fields in the Media Uploader added with attachment_fields_to_edit do not behave correctly.

Reported by: bshewmaker Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Media Keywords:
Focuses: Cc:


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.

Change History (1)

#1 @kpdesign
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #27028.

Note: See TracTickets for help on using tickets.