Jquery window.send_to_editor

后端 未结 9 1167
慢半拍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 10:04

    Here is my solution. This will allow you to upload any doc images, PDF's etc & will sort out the conflict issues that one will get with the text editors

    var uploadID = ''; // setup the var in a global scope
    var original_send_to_editor = window.send_to_editor;
    
    jQuery('.upload-button').click(function() {
        uploadID = jQuery(this).prev('input'); // set the uploadID variable to the value of the input before the upload button
        formfield = jQuery('.upload').attr('name');
        tb_show('', 'media-upload.php?TB_iframe=true');
        uploadBAR(); // Call if needed
        return false;
    });
    
    function uploadBAR() {
        window.send_to_editor = function(html) {
        imgurl = jQuery(html).attr('href');
        uploadID.val(imgurl); /*assign the value of the image src to the input*/
        tb_remove();
    
        window.send_to_editor = original_send_to_editor;//restore old send to editor function
        };
    }
    

提交回复
热议问题