我想为我的插件创建一个编辑媒体按钮,现在你可以使用WordPress 3.5媒体上传器轻松上传图像,但我希望用户能够编辑上传的图像,如下所示:
关于如何实现这一目标,有什么想法吗?
下面是我现在用来打开媒体上载程序的代码:
var file_frame;
jQuery(\'#asp_slides_upload\').live(\'click\', function(event){
event.preventDefault();
if (file_frame) {
file_frame.open();
return;
}
file_frame = wp.media.frames.file_frame = wp.media({
title: jQuery(this).data(\'uploader_title\'),
button: {
text: jQuery( this ).data(\'uploader_button_text\'),
},
multiple: true
});
file_frame.on(\'select\', function() {
var selection = file_frame.state().get(\'selection\');
var postID = jQuery(\'#asp_gallery_id\').attr(\'value\');
attachments = selection.toJSON();
printableAttachment = JSON.stringify(attachments, null, 2);
jQuery.ajax({
type: "POST",
dataType: "JSON",
url: aspAdminUrls.ajaxurl,
data: {
action: \'asp_save_slides\',
content: attachments,
postID: postID
},
success: function(data) {
jQuery(\'#asp_slides_holder\').append(data);
}
});
});
file_frame.open();
});