I found a solution: the examples do not show the fact that there should have a function called this.getstate inside the elFinder.prototype.commands.yourcommand function. It should return 0 when the icon is on, and -1 when it is off.
Thus, the complete code for adding your own menu item or context menu item is as follows:
var elf; jQuery().ready(function() { elFinder.prototype.i18.en.messages['cmdeditimage'] = 'Edit Image'; elFinder.prototype.i18.de.messages['cmdeditimage'] = 'Bild bearbeiten'; elFinder.prototype._options.commands.push('editimage'); elFinder.prototype.commands.editimage = function() { this.exec = function(hashes) { //do whatever } this.getstate = function() { //return 0 to enable, -1 to disable icon access return 0; } } ... elf = jQuery('#elfinder').elfinder({ lang: 'de', // language (OPTIONAL) url : '/ext/elfinder-2.0-rc1/php/connector.php', //connector URL width:'100%', uiOptions : { // toolbar configuration toolbar : [ ... ['quicklook', 'editimage'], /*['copy', 'cut', 'paste'],*/ ... ]}, contextmenu : { ... // current directory file menu files : [ 'getfile', '|','open', 'quicklook', 'editimage', ... ] } }).elfinder('instance'); });
Hope this helps someone with the same issue.
source share