Title: Adding fields to attachments
Last modified: August 20, 2016

---

# Adding fields to attachments

 *  Resolved [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/)
 * Love the new media uploader! But now since both `media_fields_to_edit` and `media_fields_to_save`
   are being deprecated, what is the proper way to add new fields to the media uploader?
   I understand that there is a `print_media_templates` action, but what do I do
   with that?

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234486)
 * media_fields_to_edit and media_fields_to_save filter hooks are not deprecated.
   Try WordPress release candidate 3: [http://wordpress.org/news/2012/12/wordpress-3-5-release-candidate-3/](http://wordpress.org/news/2012/12/wordpress-3-5-release-candidate-3/)
 * [http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters](http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters)
 *  Thread Starter [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234487)
 * Of course they still work, but are not the “proper” way to add to the uploader
   now. The proper way would be to utilize the new Backbone system. However, I’m
   not familiar with this so that’s what I was asking. How do I add stuff using 
   the new javascript API.
 *  Thread Starter [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234489)
 * Perhaps my question should have been “Adding views to media uploader”. How would
   I do the following from a script of my own?
 *     ```
       sidebar.set( 'compat', new media.view.AttachmentCompat({
       	controller: this.controller,
       	model:      single,
       	priority:   120
       }) );
       ```
   
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234491)
 * I’m sorry but I have no Idea, I’ve never worked with Backbone before.
    To add
   a template of your own to all other media templates with the action print_media_templates
   use something like this in your plugin or functions.php:
 *     ```
       function add_my_media_view_template(){
       // copied from wp-includes/media.php: tmpl-attachment-display-settings
       ?>
       <script type="text/html" id="tmpl-my-attachment-display-settings">
       		<h3><?php _e('My Attachment Display Settings'); ?></h3>
   
       		<# if ( 'image' === data.type ) { #>
       			<label class="setting">
       				<span><?php _e('my Alignment'); ?></span>
       				<select class="myalignment"
       					data-setting="myalign"
   
       					<option value="left">
       						<?php esc_attr_e('Left'); ?>
       					</option>
       					<option value="center">
       						<?php esc_attr_e('Center'); ?>
       					</option>
       					<option value="right">
       						<?php esc_attr_e('Right'); ?>
       					</option>
       					<option value="none" selected>
       						<?php esc_attr_e('None'); ?>
       					</option>
       				</select>
       			</label>
       		<# } #>
       </script>
       <?php  }
       add_action( 'print_media_templates', 'add_my_media_view_template');
       ```
   
 * It will be loaded on the edit post screen (look in the source code) with all 
   the other media templates. I don’t know however how to interact with it with 
   Backbone. Not very useful, I know.
 * Maybe ask around on the wp-hackers mailing list: [http://codex.wordpress.org/Mailing_Lists#Hackers](http://codex.wordpress.org/Mailing_Lists#Hackers)
 *  [Compute](https://wordpress.org/support/users/compute/)
 * (@compute)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234492)
 * Use attachment_fields_to_edit and attachment_fields_to_save. Still Works in 3.5.
 * Great tut here:
    [http://net.tutsplus.com/tutorials/wordpress/creating-custom-fields-for-attachments-in-wordpress/](http://net.tutsplus.com/tutorials/wordpress/creating-custom-fields-for-attachments-in-wordpress/)
 *  Thread Starter [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234493)
 * Really?
 * > Of course they still work, but are not the “proper” way to add to the uploader
   > now. The proper way would be to utilize the new Backbone system. However, I’m
   > not familiar with this so that’s what I was asking. How do I add stuff using
   > the new javascript API.
 *  [Andrew Nacin](https://wordpress.org/support/users/nacin/)
 * (@nacin)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234495)
 * There will be a lot of tutorials written all month on how to leverage all the
   cool new stuff in 3.5. Yes, attachment_fields_to_edit and attachment_fields_to_save
   continue to work as-is and are not deprecated.
 *  [lilike](https://wordpress.org/support/users/lili123123/)
 * (@lili123123)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234504)
 * I would very appreciate if there will be also some clue about how to hook custom(“
   Add Media” like) button with custom overlay content using JS Modal instead of
   ThickBox.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Adding fields to attachments’ is closed to new replies.

## Tags

 * [media uploader](https://wordpress.org/support/topic-tag/media-uploader/)

 * In: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
 * 8 replies
 * 5 participants
 * Last reply from: [lilike](https://wordpress.org/support/users/lili123123/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/adding-fields-to-attachments/#post-3234504)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
