WordPress 3.5 custom media upload for your theme options

后端 未结 5 858
一个人的身影
一个人的身影 2020-12-04 05:08

WordPress 3.5 has been released recently, I used the WordPress Media Upload system via thickbox and window.send_to_editor for some options in my WordPress theme

5条回答
  •  再見小時候
    2020-12-04 06:01

    I found nothing to trigger a custom function if the editor closes. I uses this:

    wp.media.editor.open();
    $('.media-modal-close, .media-modal-backdrop').one('click', function(){
        //do some stuff
    });
    

    or better:

    var id = wp.media.editor.id();
    var editor = wp.media.editor.get( id );
    if('undefined' != typeof( editor )) editor = wp.media.editor.add( id );
    
    if ( editor ) {
        editor.on('close', function(){
            //do some stuff
        });
    }
    

提交回复
热议问题