ppant
ppant

Reputation: 762

disabling file_browser_callback on insert/edit video on tinymce 4

I want to disable/hide browse button for source and other parameters in insert/edit video screen. At present I son't have back end implementation to provide the list of videos but I want this option available for insert/edit image. I am using file_browser_callback in tiny init but it looks to me that a same file_browser_callback is used to handle the browse for all the screen. Can someone suggest me a way to hide the browse for "insert/edit" video plugins but allow in "insert/edit image"?

Please check Fiddle

Upvotes: 1

Views: 1447

Answers (2)

jpCharger
jpCharger

Reputation: 117

TinyMCE has provided a way to do this by using file_picker_types. You will need to add this to the tinymce.init, maybe right above your "file_browser_callback:"

file_picker_types: 'image',

https://www.tinymce.com/docs/configure/file-image-upload/#file_picker_types

Upvotes: 1

tvgemert
tvgemert

Reputation: 1486

There is indeed one file_browser_callback but within the callback you can target different types. In my implementation I've done the following:

   file_browser_callback: function(field_name, url, type, win) { 
        if (type == 'file') {
            diaTitle = 'Insert link';
            browser = '/linkmanager/index.php'+'?field_id='+field_name;
        } else if (type == 'image') {
            diaTitle = 'Insert image';
            browser = '/filemanager/dialog.php?type=1&field_id='+field_name;
        }   
        tinymce.activeEditor.windowManager.open({
            title: diaTitle,
            url: browser,
            width: 860,
            height: 600
        },{
            oninsert: function(url) {
                win.document.getElementById(field_name).value = url; 
            }
        });
    }

Hope this can help you!

Upvotes: 1

Related Questions