Drupal 7: Disable CKEditor Bundled Plugin(s)

CKEditor library 4.x comes with many plugins. Sometimes we may want to disable one or more of that bundled plugins. It may be to reduce page load, to avoid conflict with some other JavaScript solutions including CKEditor plugins, etc. Here I show how we can achieve it within Drupal ecosystem.

CKEditor Module

CKEditor module provides the hook hook_ckeditor_settings_alter(). That can be used to disable the plugin(s) as shown below:

/**
 * Implements hook_ckeditor_settings_alter()
 */
function MYMODULE_ckeditor_settings_alter(&$settings, $conf) {
  // Comma separate names of plugins to remove.
  $plugins_to_remove = 'image,image2';
  $settings['removePlugins'] = !empty($settings['removePlugins'])
    ? $settings['removePlugins'] . ',' . $plugins_to_remove
    : $plugins_to_remove;
}

In above example, we are disabling image and image2 plugins that comes bundled with CKEditor library package.

WYSIWYG Module

If you are using wysiwyg module, then it also has similar hook hook_wysiwyg_editor_settings_alter. That can be used in same way to disable plugin(s).


/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    // Comma separate names of plugins to remove.
    $plugins_to_remove = 'image,image2';
    $settings['removePlugins'] = !empty($settings['removePlugins'])
      ? $settings['removePlugins'] . ',' . $plugins_to_remove
      : $plugins_to_remove;
  }
}

Please replace MYMODULE with your module name in both examples.