Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the new WP media manager for a branding plugin (well, new from 3.5), and it is working well.

My only issue is that I have an 'Attachment Details' area on the right, allowing users to edit, delete and generally mess with images.

Is there a way to remove this area? Thanks.

Here is an image showing which area I want to eliminate - enter image description here

Here is my JS to invoke the media manager -

$(document).ready(function(){

    var dd_media_frame,     // The custom dd_media frame
        clicked_parent = 0; // The parent element of the button that was clicked

    /** Open the media manager when the any button with the class 'open-media-manager' is clicked*/
    $('#dd-custom-branding-metabox').on('click', '.manage-images-button', function(e){

        e.preventDefault();

        clicked_parent = $(this).parent();

        /** Ensure the 'dd_media_frame' media manager instance already exists (i.e. if it's already been used since the page was loaded) */
        if(!dd_media_frame){

            dd_media_frame = wp.media.frames.dd_media_frame = wp.media({

                /** Set the parameters for the media uploader */
                button: { text: 'Select image' },                           // Set the text of the button.
                className: 'media-frame custom-admin-branding-media-frame', // The class to use for this instance of the media manager
                library: { type: 'image' },                                 // Ensure only images are allowed
                multiple: false,                                            // Disable multiple selections
                title: 'Select a custom admin header image'                 // The tile to show in the media uploader
            });

            dd_media_frame.on('select', function(){

                /** Grab the attachment selection and construct a JSON representation of the model */
                var media_attachment = dd_media_frame.state().get('selection').first().toJSON();

                /** Update the hidden 'branding[header_logo]' field with the ID of the selected logo */
                clicked_parent.find('input[name="branding[header_logo]"]', '#dd-custom-branding-metabox').val(media_attachment.id);

            });

        }

        /** Finally, open the media manager */
        dd_media_frame.open();

    });

});
share|improve this question
add comment

2 Answers 2

I use CSS for that:

add_action('admin_head-post.php', 'hide_media_stuff_wpse_120894' );
add_action('admin_head-post-new.php', 'hide_media_stuff_wpse_120894' );

function hide_media_stuff_wpse_120894(){
    ?>
    <style type="text/css">
        .attachment-details [data-setting="title"],
        .attachment-details [data-setting="caption"],
        .attachment-details [data-setting="alt"],
        .attachment-details [data-setting="description"],
        div.attachment-display-settings
        {
            display:none
        }
    </style>
    <?php
}

media library

share|improve this answer
add comment

Have you tried to remove it with js before opening the manager?

$(document).ready(function(){

    var dd_media_frame,     // The custom dd_media frame
        clicked_parent = 0; // The parent element of the button that was clicked

    /** Open the media manager when the any button with the class 'open-media-manager' is clicked*/
    $('#dd-custom-branding-metabox').on('click', '.manage-images-button', function(e){

        e.preventDefault();

        clicked_parent = $(this).parent();

        /** Ensure the 'dd_media_frame' media manager instance already exists (i.e. if it's already been used since the page was loaded) */
        if(!dd_media_frame){

            dd_media_frame = wp.media.frames.dd_media_frame = wp.media({

                /** Set the parameters for the media uploader */
                button: { text: 'Select image' },                           // Set the text of the button.
                className: 'media-frame custom-admin-branding-media-frame', // The class to use for this instance of the media manager
                library: { type: 'image' },                                 // Ensure only images are allowed
                multiple: false,                                            // Disable multiple selections
                title: 'Select a custom admin header image'                 // The tile to show in the media uploader
            });

            dd_media_frame.on('select', function(){

                /** Grab the attachment selection and construct a JSON representation of the model */
                var media_attachment = dd_media_frame.state().get('selection').first().toJSON();

                /** Update the hidden 'branding[header_logo]' field with the ID of the selected logo */
                clicked_parent.find('input[name="branding[header_logo]"]', '#dd-custom-branding-metabox').val(media_attachment.id);

            });

        }

        /** Finally, open the media manager */
        $('.attachment-details').remove(); /* or .hide(), there might be hidden inputs */
        dd_media_frame.open();

    });

});

Another option is to find in your files attachment-details and coment/remove the container

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.