请检查以下代码。这在Firefox和Chrome上工作正常,但在Internet Explorer 11上出现以下错误。因此,所需的wordpress图像弹出功能无法在IE上运行。
SCRIPT5007:无法获取未定义或空引用的属性
$(document).on('click', '.dfiFeaturedImage', function() {
current = $(this);
if( null !== current) {
var dfi_uploader = wp.media({
title: WP_SPECIFIC.mediaSelector_title,
button: {
text: WP_SPECIFIC.mediaSelector_buttonText
},
multiple: false,
}).on('select', function() {
var attachment = dfi_uploader.state().get('selection').first().toJSON(),
fullSize = attachment.url,
imgUrl = (typeof attachment.sizes.thumbnail === "undefined") ? fullSize : attachment.sizes.thumbnail.url,
imgUrlTrimmed, fullUrlTrimmed;
imgUrlTrimmed = imgUrl.replace(WP_SPECIFIC.upload_url, "");
fullUrlTrimmed = fullSize.replace(WP_SPECIFIC.upload_url, "");
var featuredBox = current.parent();
featuredBox.find('.fImg').attr({
'src': imgUrl,
'data-src': fullSize
});
featuredBox.find('.dfiFeaturedImage').addClass('hasFeaturedImage');
var dfiFeaturedImages = [imgUrlTrimmed, fullUrlTrimmed];
/**
* Check if medium sized image exists
* @type object
*/
var medium = attachment.url;
if( typeof attachment.sizes.medium !== "undefined" ) {
medium = attachment.sizes.medium.url;
}
featuredBox.find('img').attr('src', medium).fadeIn(200);
featuredBox.find('input.dfiImageHolder').val(dfiFeaturedImages);
}).open();
}
return false;
});