【问题标题】:Thickbox not closing after inserting media in Wordpress在 Wordpress 中插入媒体后,Thickbox 未关闭
【发布时间】:2012-12-21 12:04:57
【问题描述】:

我正在使用 Wordpress 厚框来尝试重新运行用户想要选择的图像的值(当他们单击“插入帖子”时),但厚框没有关闭,只是显示为任何空白框.

$('#office-image input#image') 字段存在,Firebug 不会报告任何错误。

我不确定为什么这不起作用,因此需要任何帮助。谢谢。

window.send_to_editor = function(html){

    var image_url = $('img', html).attr('src');

    $('#office-image input#image').val(image_url);
    tb_remove();

}

【问题讨论】:

  • 检查错误控制台可能是由于通过firebug控制台进行jQuery检查而发生的

标签: wordpress thickbox


【解决方案1】:
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function (html) {
    var fileInput = jQuery(fileInput_id);
    if (fileInput) {
        fileurl = jQuery('img', html).attr('src');
        jQuery(fileInput).val(fileurl);
        tb_remove();

    } else {
        window.original_send_to_editor(html);
    }
};

我正在使用上面的脚本,它工作正常

【讨论】:

  • 您使用的是jQuery,而不是$,这让我找到了答案。这是因为我忘记通过jQuery(document).ready(function($){ 传递$。谢谢。
猜你喜欢
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 2014-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多