attachment_fields_to_edit

Filter the attachment fields to edit.

Description

apply_filters( 'attachment_fields_to_edit', (array) $form_fields, (WP_Post) $post ); 

Parameters (2)

0. $form_fields (array)
An array of attachment form fields.
1. $post (WP_Post)
The WP_Post attachment object.

Usage

To run the hook, copy the example below.
  1. $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); 
  2.  
  3. if ( !empty( $form_fields ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the attachment_fields_to_edit callback 
  2. function filter_attachment_fields_to_edit( $form_fields, $post ) { 
  3. // make filter magic happen here... 
  4. return $form_fields
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'attachment_fields_to_edit', 'filter_attachment_fields_to_edit', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'attachment_fields_to_edit', 'filter_attachment_fields_to_edit', 10, 2 ); 

Defined (2)

The filter is defined in the following location(s).

/wp-admin/includes/media.php  
  1. $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); 
  1. $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );