diff --git a/ckeditor.module b/ckeditor.module
index 450fc7c..3dbcb31 100644
--- a/ckeditor.module
+++ b/ckeditor.module
@@ -361,14 +361,15 @@ function ckeditor_module_path($mode = 'relative') {
  *   Path of library in the Drupal installation.
  */
 function ckeditor_library_path($mode = 'relative') {
+  $ckeditor_path = module_exists('libraries') ? substr(libraries_get_path('ckeditor'), 0, -9) : 'sites/all/libraries';
   switch ($mode) {
     default:
     case 'relative':
-      return ckeditor_base_path('relative') . '/sites/all/libraries';
+      return ckeditor_base_path('relative') . '/' . $ckeditor_path;
     case 'local':
-      return ckeditor_base_path('local') . '/sites/all/libraries';
+      return ckeditor_base_path('local') . '/' . $ckeditor_path;
     case 'url':
-      return 'sites/all/libraries';
+      return $ckeditor_path;
   }
 }
 
@@ -684,4 +685,4 @@ function ckeditor_modules_uninstalled($modules) {
           ->execute();
     }
   }
-}
\ No newline at end of file
+}
diff --git a/includes/ckeditor.admin.inc b/includes/ckeditor.admin.inc
index 34ff1f0..b8a4d55 100644
--- a/includes/ckeditor.admin.inc
+++ b/includes/ckeditor.admin.inc
@@ -769,7 +769,7 @@ function ckeditor_admin_profile_form($form, $form_state, $profile = NULL) {
     drupal_add_js(array('ckeditor_uicolor' => $color_palette), 'setting');
   }
 
-  drupal_add_js('window.CKEDITOR_BASEPATH = "' . $editor_path . '/"', array('type' => 'inline', 'weight' => -100));
+  drupal_add_js('window.CKEDITOR_BASEPATH = "' . ckeditor_library_path('url') . '/"', array('type' => 'inline', 'weight' => -100));
   drupal_add_js($editor_url_path . '/ckeditor.js', array('type' => 'file', 'preprocess' => FALSE));
   drupal_add_js($module_drupal_url_path . '/ckeditor.config.js', 'file');
   drupal_add_js($module_drupal_url_path . '/includes/ckeditor.admin.js', 'file');
diff --git a/includes/ckeditor.lib.inc b/includes/ckeditor.lib.inc
index 5d55f39..655b836 100644
--- a/includes/ckeditor.lib.inc
+++ b/includes/ckeditor.lib.inc
@@ -1397,7 +1397,7 @@ function ckeditor_load_by_field($field, $format, $show_toggle = TRUE, $add_field
         $load_method = $profile->settings['ckeditor_load_method'];
         $load_time_out = $profile->settings['ckeditor_load_time_out'];
       }
-      drupal_add_js('window.CKEDITOR_BASEPATH = "' . ckeditor_path('relative') . '/"', array('type' => 'inline', 'weight' => -100));
+      drupal_add_js('window.CKEDITOR_BASEPATH = "' . ckeditor_library_path('url') . '/"', array('type' => 'inline', 'weight' => -100));
       drupal_add_js(ckeditor_module_path('url') . '/includes/ckeditor.utils.js', array('type' => 'file', 'scope' => 'footer'));
 
       $preprocess = FALSE;
