I just ran into this. The reason is that you are overriding the window.send_to_editor
function with one of your own. WordPress uses this function to insert galleries and other stuff, so now that you’ve changed it, it can’t.
Ideally’ you’d want to use an event triggered by the media uploader instead of just replacing the function, or at least replacing it temporarily while making a backup, something like this (the wp admin uses underscore.js):
myBtn.on('click', function() {
var bkSend = _.clone(window.send_to_editor); // we need a copy
//... My code
window.send_to_editor = function(html) {
//... My custom things
restore();
}
function restore() {
window.send_to_editor = bkSend;
}
});
Untested.
Ok so a tested and working version for my case:
(function($) {
$(document).ready(function() {
$('#upload_image_button').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
tb_show('', 'media-upload.php?post_id=<?php echo $post->ID; ?>&type=image&TB_iframe=true');
var bkSend = _.clone(window.send_to_editor);
var restore = function(callBack) {
window.send_to_editor = _.clone(bkSend);
callBack();
};
//console.log(bkSend);
window.send_to_editor = function(html) {
imgurl = $(html).find('img').attr('src');
$('#lc-slider-image')[0].src = imgurl;
$('#lc_slider_image').val(imgurl);
restore(tb_remove);
};
//console.log(window.send_to_editor);
});
});
})(jQuery);
I hope it helps some of the victims of that dreadful blog post that started all this madness.
I’m too busy to beautify that code and it certainly could be better so if someone could help me with that it would be great.