1
我正在创建一个自定义主题,其中我创建了WordPress媒体上传器的实例以将视频文件上传到给定部分。这是我的JS代码:添加自定义选项卡到自定义媒体请求者屏幕
//click function on the video requester
$('.video_requester')
.on('click', function (e) {
e.preventDefault();
var divisionID = String(e.target.id); // the id of the clicked div
var custom_uploader = wp.media({
title: 'Add Video To Section',
button: {
text: 'Save Video'
},
library: {
type: 'video'
},
multiple: false, // Set this to true to allow multiple files to be selected
//frame: 'post'// uncomment to see the post frame
})
.on('select', function() {
var attachment = custom_uploader.state()
.get('selection')
.first()
.toJSON();
var extension = attachment.url.substr((attachment.url.lastIndexOf('.') + 1)); //read what is after the last.
alert(attachment.url);
})
.open();
});
我想添加一个额外的选项卡到媒体请求者弹出。
感谢你。我已经使用其他一些复杂的hack(创建我自己的视图)实现了这一点,但是当您与自定义视图进行交互时,模式不会关闭。这看起来很干净而且很有希望。将很快发布我的完整代码。 – Cyrusville 2014-11-09 14:50:56