Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在可视化编辑器中添加wordpress文件选择器_Wordpress_Tinymce - Fatal编程技术网

在可视化编辑器中添加wordpress文件选择器

在可视化编辑器中添加wordpress文件选择器,wordpress,tinymce,Wordpress,Tinymce,我想知道如何添加一个文件选择器,默认的wordpress库将完美地添加到我的tinymce可视化编辑器的弹出窗口中 目前,我有一个字段,我必须通过图片的url,如果我可以添加一个按钮,从我的库中选择图片,这将是伟大的 这是我到目前为止所拥有的 editor.addButton('thumbnail', { title: 'Thumbnail', image: url+'/../images/icon-thumbnail.png',

我想知道如何添加一个文件选择器,默认的wordpress库将完美地添加到我的tinymce可视化编辑器的弹出窗口中

目前,我有一个字段,我必须通过图片的url,如果我可以添加一个按钮,从我的库中选择图片,这将是伟大的

这是我到目前为止所拥有的

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);
                        }
                    }
                });
            }
        });
你可以阅读有用的文章,也可以有所帮助

我不想复制粘贴文章中的文本,但基本上,您必须在主题的functions.PHP文件中创建自定义PHP函数,该函数将处理媒体对话框显示,然后将其包含在事件管理的add_action_print_脚本中

最后一部分是使用一些JavaScript和其中的上载程序,如下所示:

jQuery(document).ready(function() {

jQuery('#upload_image_button').click(function() {
 formfield = jQuery('#upload_image').attr('name');
 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
 return false;
});

window.send_to_editor = function(html) {
 imgurl = jQuery('img',html).attr('src');
 jQuery('#upload_image').val(imgurl);
 tb_remove();
}

});

下面是如何在TinyMCE中添加自定义按钮:您所需要做的就是调整有关TinyMCE init的wordpress设置。抱歉,如果我不清楚,我已经有了我的按钮,它会呈现我的弹出窗口图片附加到我的问题事实上,我只需要用文件选择器替换弹出窗口中的文本字段