Jquery window.send_to_editor

后端 未结 9 1172
慢半拍i
慢半拍i 2020-12-24 09:22

Couldn\'t come up with a good title for this.

I\'ve got a build in WordPress where I have multiple image uploads using the built in WordPress media uploader. How it\

9条回答
  •  既然无缘
    2020-12-24 09:59

    This example restores the window.send_to_editor() func by binding the tb_unload event as soju mentioned above.

    var targetfield = '';
    var orig_send_to_editor = window.send_to_editor;
    jQuery('.fwb_uploadbtn').click(function() {
          targetfield = jQuery(this).prev('.fwb_uploadimg');
          tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    
          //restore send_to_editor() when tb closed
          jQuery("#TB_window").bind('tb_unload', function () {
            window.send_to_editor = orig_send_to_editor;
          });
    
          //temporarily redefine send_to_editor()
          window.send_to_editor = function(html) {
            imgurl = jQuery('img',html).attr('src');
            jQuery(targetfield).val(imgurl);
            tb_remove();
          }
          return false;
    });
    

提交回复
热议问题