Forum

Thread tagged as: Question, Redactor

Image and File buttons not showing in customized Redactor

I am on Perch 3. I made my customized version of Redactor. All works fine exept the buttons for images and files. I tried first to use the built-in version, then the plugins from Redactor. Both are not working. Here is my config-file:

Perch.UserConfig.redactor = function() {

var get = function(profile, config, field) {

if (config.plugins.indexOf('source') === -1) config.plugins.push('source');
if (config.plugins.indexOf('table') === -1) config.plugins.push('table');
if (config.plugins.indexOf('video') === -1) config.plugins.push('video');
if (config.plugins.indexOf('imagemanager') === -1) config.plugins.push('imagemanager');
if (config.plugins.indexOf('filemanager') === -1) config.plugins.push('filemanager');

// adding plugins automatically loads a button for each plugin
// so default toolbar config increases from usual default of 9 buttons (format, bold, italic, deleted, lists, image, file, link, horizontalrule)
// .. to 14 buttons
// Define customised editor configs by what buttons should be hidden (from the original default of 9 buttons) and which specific plugins (from those listed above) should be loaded
if (profile == 'content') {
// do nothing; all required buttons and plugins are loaded by default
}
if (profile == 'simple') {
return { 
buttonsHide: ['italic', 'deleted', 'horizontalrule'],
formatting :['p','h2', 'h3'],
plugins: ['source', 'table', 'video']
}
}
if (profile == 'minimal') {
return { 
buttonsHide: ['format', 'italic', 'deleted', 'lists', 'horizontalrule'],
formatting :['p'],
plugins: ['source']
}
}

return config;

};

var load = function(cb) {

if (typeof jQuery.Redactor.prototype.source == 'undefined') {
jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/source.js', function() {
jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/table.js', function() {
jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/video.js', function() {
jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/imagemanager.js', function() {
jQuery.getScript(Perch.path + '/addons/plugins/editors/redactor-plugins/filemanager.js', cb);
});
});
});
});
} else {
cb();
}

};

return {
'get': get,
'load': load
}

}();

Actually I would prefer to use the built-in buttons, but I should also be able to disable them if required. Your help is much appreciated!

Martin Stettler

Martin Stettler 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Did you say the default configuration isn't working? If so, please detail what's happening.

When I use profile «content» it loads all buttons and all available plugins as long as I don't save a new textarea element. If I do so image and file buttons disapear. What I would like to use are the default buttons for image and file. And to be able to hide them. This still does not work, they both disapear when I hide for example only the image button. Have you any idea how to solve this? Thanks a lot!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is it working without your customisations?

Without customizations (profile content) it works fine, I see all buttons and plugins. When I change to another profile (simple or minimal) buttons for image and file are no longer visible and the plugins imagemanager and filemanager aren't available either. So, probably the fault is in the return part?

return { 
buttonsHide: ['italic', 'deleted', 'horizontalrule'],
formatting :['p','h2', 'h3'],
plugins: ['source', 'table', 'video']
}

Any suggestions? Many thanks, Drew!

Drew McLellan

Drew McLellan 2638 points
Perch Support

It does sound like the problem is in your code somewhere.

Obviously. I am using the same script described here: https://forum.grabaperch.com/forum/08-12-2017-custom-plugin-buttons-not-displaying-in-redactor-toolbar?page=1#reply-52739

The question is how can I include the image and file buttons in a custom config? I've tried a number of configs, but as a result I either get: - the default toolbar with all buttons and plugins - so no custom config, or - the custom config in various ways but always without the image and file buttons

Did you tried once to solve this?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you mean the standard plugins, or my custom versions?

Drew McLellan

Drew McLellan 2638 points
Perch Support

The custom buttons are called perchassets_img and perchassets_file.

My problem was that I was calling them always separatly, now with the correct syntax brought in this thread (https://forum.grabaperch.com/forum/08-12-2017-custom-plugin-buttons-not-displaying-in-redactor-toolbar?page=2#reply-54621) it works fine. Thanks Drew!

plugins: ['perchassets']