2
我想知道如何在tinymce可視化編輯器的彈出框中添加文件選擇器(默認的wordpress圖書館應該是完美的)。在可視化編輯器中添加wordpress文件選取器
此刻我有一個領域,我必須通過圖片的網址,如果我可以添加一個按鈕從我的圖書館中選擇一張圖片,那就太好了!
這裏是我迄今爲止
editor.addButton('thumbnail', {
title: 'Thumbnail',
image: url+'/../images/icon-thumbnail.png',
onclick: function() {
// Open window
editor.windowManager.open({
title: 'Thumbnail',
width: 940,
height: 150,
body: [
//I have to change this line---------> {type: 'textbox', name: 'url', label: 'Media URL'},<----- Is there an option to put a filepicker here ?
{type: 'textbox', name: 'caption', label: 'Caption'},
{type: 'checkbox', name: 'lightbox', value: '1', label: 'Lightbox'}
],
onsubmit: function(e) {
if(e.data.url==''){
alert('you have to provide the media\'s URL');
e.stopPropagation();
e.preventDefault();
}else{
// Insert content when the window form is submitted
var shortCode = '[thumbnail url="'+e.data.url+'"';
if(e.data.caption != ''){
shortCode = shortCode+' caption="'+e.data.caption+'"';
}
if(e.data.lightbox){
shortCode = shortCode+' lightbox=true';
}
shortCode = shortCode+' ]';
editor.insertContent(shortCode);
}
}
});
}
});
這裏是你如何可以添加TinyMCE的自定義按鈕:http://www.tinymce.com/wiki。 php/API3:method.tinymce.Editor.addButton你所需要做的只是調整你的wordpress設置,關於tinymce init。 – bodi0 2014-08-29 14:11:01
對不起,如果我不清楚,我已經有我的按鈕,它會渲染我的彈出窗口(圖片附加到我的問題)實際上,我只需要替換文件選擇器在該彈出文本字段 – 0x1gene 2014-08-29 14:18:56