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