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