我有以下代码,我以前曾在自定义插件页面中成功打开wordpress媒体上传器。
var custom_uploader;
jQuery('#uploadButton').click(function(e) {
e.preventDefault();
//Extend the wp.media object
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Choose Image',
button: {
text: 'Choose Image'
},
multiple: false
});
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader.on('select', function() {
var attachment = custom_uploader.state().get('selection').first().toJSON();
alert(attachment.url);
});
//Open the uploader dialog
custom_uploader.open();
});
现在失败并显示消息"上传时出错。请稍后再试。"。我在这里做错了吗?