【发布时间】:2016-06-01 21:47:37
【问题描述】:
我在 Wordpress 中使用 Metabox 插件,它带有thickbox 选项。
一切正常,除了尝试使用多张图片上传创建/编辑画廊。
当我点击“插入图库”按钮时,什么也没有发生,我在 chrome 控制台中注意到:
Uncaught TypeError: Cannot read property 'replace' of undefined
文件内容如下
jQuery( function ( $ )
{
'use strict';
$( 'body' ).on( 'click', '.rwmb-thickbox-upload', function ()
{
var $this = $( this ),
$holder = $this.siblings( '.rwmb-images' ),
post_id = $( '#post_ID' ).val(),
field_id = $this.data( 'field_id' ),
backup = window.send_to_editor;
window.send_to_editor = function ( html )
{
var $img = $( '<div />' ).append( html ).find( 'img' ),
url = $img.attr( 'src' ),
img_class = $img.attr( 'class' ),
id = parseInt( img_class.replace( /\D/g, '' ), 10 );
html = '<li id="item_' + id + '">';
html += '<img src="' + url + '">';
html += '<div class="rwmb-image-bar">';
html += '<a class="rwmb-delete-file" href="#" data-attachment_id="' + id + '">×</a>';
html += '</div>';
html += '<input type="hidden" name="' + field_id + '[]" value="' + id + '">';
html += '</li>';
$holder.append( $( html ) ).removeClass( 'hidden' );
tb_remove();
window.send_to_editor = backup;
};
tb_show( '', 'media-upload.php?post_id=' + post_id + '&TB_iframe=true' );
return false;
} );
} );
这是给出错误的行
id = parseInt( img_class.replace( /\D/g, '' ), 10 );
【问题讨论】:
-
您好,您找到解决此问题的方法了吗?好像没有人这么看。如果您能分享这个问题的前进方向,将不胜感激,谢谢。
-
@user3619389 - 我现在也遇到同样的错误,到目前为止似乎找不到主要问题。
-
我也找不到问题,我用其他方法来克服这个不是元框,...