WordPress 3.5:切换回旧媒体上传器?

时间:2013-01-16 作者:Sal

有没有办法切换回WordPress 3.5中的旧媒体上传程序?新的对我来说速度很慢,因为我的网站上有成千上万的图片,而且我有几个插件只能与旧的上传程序一起使用。

1 个回复
SO网友:brasofilo

我刚在WordPress论坛上找到这个宝石A.Morita.

Is there a way to disable the new Media Manager?

总结所有已发布的代码,如下所示:

/**
 * I WANT THE OLD UPLOADER BACK
 * All code by: A.Morita
 * URL: http://wordpress.org/support/topic/is-there-a-way-to-disable-the-new-media-manager/
 */

/**
 * Old upload Thickbox
 */
add_action( \'admin_head\', \'remove_media_buttons\' );

function remove_media_buttons()
{
    remove_action( \'media_buttons\', \'media_buttons\' );
    add_action( \'media_buttons\', \'old_media_buttons\' );
}

function old_media_buttons( $editor_id = \'content\' ) 
{
    $context = apply_filters( \'media_buttons_context\', __(\'Upload/Insert %s\') );
    
    $img = \'<img src="\' 
        . esc_url( admin_url( \'images/media-button.png?ver=20111005\' ) ) 
        . \'" width="15" height="15" />\';
        
    echo \'<a href="\' 
        . esc_url( get_upload_iframe_src() ) 
        . \'" class="thickbox add_media" id="\' 
        . esc_attr( $editor_id ) 
        . \'-add_media" title="\' 
        . esc_attr__( \'Add Media\' ) 
        . \'" onclick="return false;">\' 
        . sprintf( $context, $img ) 
        . \'</a>\';
}

/**
 * Featured image
 */
add_action( \'wp_default_scripts\', \'unset_media_views\', 999, 1 );
add_action( \'admin_head\', \'remove_wp_print_media_templates\' );

function unset_media_views($scripts)
{
    unset( $scripts->registered[\'media-views\'] );
}
    
function remove_wp_print_media_templates()
{
    remove_action( \'admin_footer\', \'wp_print_media_templates\' );
    remove_action( \'wp_footer\', \'wp_print_media_templates\' );
}


/**
 * Adjust Full Screen behavior
 */
add_action( \'after_wp_tiny_mce\', \'fullscreen_media_button\' );

function fullscreen_media_button()
{
    ?>
    <script type="text/javascript">
    fullscreen.medialib = function() 
    {
        var href = jQuery(\'div#wp-content-media-buttons a.thickbox\').attr(\'href\') || \'\';
        tb_show(\'\', href);
    }
    </script>
    <?php
}
Wrapped as a plugin in Gist.

结束

相关推荐

通过Media Uploader自动将图像添加到特定页面

我有一个插件,可以调用媒体上传程序,允许用户向页面添加图像。上传程序正在显示并拍摄图像,但它没有如我所愿将其附加到页面ID 65(或在图库中显示附加到该页面的图像)。我是否遗漏了什么,或者这在WP中是不可能的?谢谢jQuery(document).ready(function($){ $(\'.manage-images-button a.button-secondary\').on(\'click\', function(){ tb_show(