February 4, 2013

How to get CKEditor 4.x working with the Drupal 7 WYSIWYG module

Filed under: Tips — Tags: , , , — Webopius @ 10:03 am

Another quick tip.

The Drupal 7 WYSIWYG module allows you to choose an editor that’s best for you including the renamed FCKEditor, now called CKEditor.

However, for those of you using CKEditor 4.0 or higher, you might see the following error message after you’ve downloaded CKEditor into your sites/all/libraries directory:

“The version of CKEditor could not be detected.”

This issue is caused because the WYSIWYG editor reads the CKEditor.js file and does a pattern match looking for the version number. In older CKEditor releases, this string looked like this:


In newer versions, it’s changed very slightly to this:


Notice the change from single to double quotes?

This stops WYSIWYG detecting the version, hence the error.

The Fix

Edit ‘\sites\all\modules\wysiwyg\ckeditor.inc’ and at about line 83, replace this line:

if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {

With this (just replace the two ‘s with “)

if (preg_match('@version:\"(?:CKEditor )?([\d\.]+)(?:.+revision:\"([\d]+))?@', $line, $version)) {

All will now be ok

  • Tags