Remove fields from attachment details of the New WordPress Media Manager

The new Media Manager looks terrific, really nice, however, as in the previous version, it have a few fields in the Attachment details that I’d like to avoid, I used to use this code:

add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2);
function remove_media_upload_fields( $form_fields, $post ) {

    unset( $form_fields['image_alt'] );
    unset( $form_fields['post_content'] );
    unset( $form_fields['post_excerpt'] );
    unset( $form_fields['url'] );
    unset( $form_fields['image_url'] );
    unset( $form_fields['align'] );
    unset( $form_fields['image-size'] );

    return $form_fields;
}

But seems like it doesn’t work in the new Version.

Read More

How could I remove those fields in the New Media Manager?

Related posts

Leave a Reply

1 comment

  1. I had trouble with this one as well. There are a few workarounds, but I found that the following worked best… when you click “Add Featured Image” from the editor page (the metabox link), the options for “insert into post” and all of the options you mention are missing from the media manager. This was perfect for me, as I wanted to remove the option for users to insert images into posts. If this is what you’re after, put this code in your theme’s functions.php file…

    /**
    * Add if you want to remove image edit option from Media Manager.
    */
    add_action( 'admin_footer-post-new.php', 'wpse_76214_script' );
    add_action( 'admin_footer-post.php', 'wpse_76214_script' );
    function wpse_76214_script() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready( function($) {
        $( 'li.attachment' ).live( 'click', function( event ) {
            $( '.media-sidebar a.edit-attachment' ).remove(); // remove edit image link
        });
    } );
    </script>
    <?php
    }
    
    /**
    * Removes "Add Media" Button from the editor.
    */
    function z_remove_media_controls() {
    remove_action( 'media_buttons', 'media_buttons' );
    }
    add_action('admin_head','z_remove_media_controls');
    
    /**
    * Takes over the "Featured Image" meta box and allows you to change its options.
    */
    add_action('do_meta_boxes', 'change_image_box');
    function change_image_box()
    {
    remove_meta_box( 'postimagediv', 'post', 'side' );
    remove_meta_box( 'postimagediv', 'page', 'side' );
    // if you have other post types, remove the meta box from them as well
    // remove_meta_box( 'postimagediv', 'your-post-type', 'side' );
    add_meta_box('postimagediv', __('Add Images'), 'post_thumbnail_meta_box', 'post', 'side' );
    add_meta_box('postimagediv', __('Add Images'), 'post_thumbnail_meta_box', 'page', 'side' );
    }
    
    /**
    * Renames Feature Image Link that appears inside meta box.
    */
    add_action('admin_head-post-new.php',change_thumbnail_html);
    add_action('admin_head-post.php',change_thumbnail_html);
    function change_thumbnail_html( $content ) {
      add_filter('admin_post_thumbnail_html',do_thumb);
    }
    function do_thumb($content){
     return str_replace(__('Set featured image'), __('Add Images and Set Featured'),$content);
    }
    

    Users will now only be able to add images by clicking on the link in the meta box, which is now named “Add Images.” Additionally, the link within the meta box has been changed to avoid confusion. Hope this helps!