Home / admin / Attachment window hide buttons and input fields
  • How to Attachment window hide buttons and input fields

    attachment-window-hide-buttons-and-input-fields

    Adding this snippet to the functions.php of your wordpress theme will allow you to hide buttons and input fields within the media attachment window.

    ( example screenshot )

    wordpress snippet : PHP

    <>
    function attachment_fields($form_fields, $post) {
        if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
            $form_fields['image_alt']['value'] = '';
            $form_fields['image_alt']['input'] = 'hidden';
            $form_fields['post_excerpt']['value'] = '';
            $form_fields['post_excerpt']['input'] = 'hidden';
            $form_fields['post_content']['value'] = '';
            $form_fields['post_content']['input'] = 'hidden';
            $form_fields['url']['value'] = '';
            $form_fields['url']['input'] = 'hidden';
            $form_fields['align']['value'] = 'aligncenter';
            $form_fields['align']['input'] = 'hidden';
            $form_fields['image-size']['value'] = 'thumbnail';
            $form_fields['image-size']['input'] = 'hidden';
            $form_fields['image-caption']['value'] = 'caption';
            $form_fields['image-caption']['input'] = 'hidden';
            $form_fields['buttons']['input'] = 'hidden';
        }
        return $form_fields;
    }
    add_filter('attachment_fields_to_edit', 'attachment_fields', 15, 2 );
    

    ( WordPress codex functions, hooks, in this snippet. )

    attachment_fields_to_edit, add_filter, _e, _ex, wp,
  • louisville chiropractic

    i want to try this in one of my wordpress.

    • http://wpsnipp.com Kevin Chard

      Sure just copy and paste the code into your functions.php file and you will be ready to go.

  • Wcardinal

    is it possible to show “All Types” instea dof “Images” as the default view in the “Media Library” tab?

  • http://fsch.ro/ Florian Schroiff

    I wonder if there is a way to influence the order of fields. My caption field is now always the last one…