删除WordPress媒体管理器的“附件详细信息”部分

时间:2013-11-01 作者:David Gard

我正在使用新的WP media manager作为品牌插件(好吧,是3.5版的新插件),它工作得很好。

我唯一的问题是,我在右侧有一个“附件详细信息”区域,允许用户编辑、删除和处理图像。

有没有办法移除这个区域?谢谢

这是一张显示我要消除哪个区域的图像-enter image description here

这是我的JS,用于调用媒体管理器-

$(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();

    });

});

2 个回复
最合适的回答,由SO网友:brasofilo 整理而成

我使用CSS:

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

SO网友:Toni Michel Caubet

在打开manager之前,您是否尝试使用js删除它?

$(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();

    });

});
另一种选择是在文件中查找attachment-details 并取出/取出容器

结束

相关推荐