Upgrading media and CKEditor to get WYSIWYG plugin to work

You shouldn't see any difference in this website, but I've just upgraded Media from the 1.x to 2.x branches, and so far nothing seems to have broken. I did this in order to get the media browser to appear in my rich-text editor: this has turned into a yak-shaving expedition, involving switching my rich-text editor of choice to CKEditor and switching WYSIWYG to its dev branch.

Upgrading Media (and File Entity)

As an upgrade path, this option has been available for some time, but there are some horror stories out there; also, Media 7.x-2.x is still in alpha.

Despite some complex recipes out there for upgrading, it's really pretty straightforward now:

  1. Remove the media module's folder
  2. Download media 2.x and the (now separate) file_entity project
  3. Run all database schema updates

Indeed, the only complication is that file_entity is now a separate Drupal project, so make sure you download both. Here's a one-liner I ran in my modules/ folder, which chained the required tasks:

$ rm -rf media/ && drush dl file_entity media-7.x-2.0-alpha3 && drush updb

Once everything's updated, you will probably want to reconfigure file_entity permissions, as any old 1.x permissions were tied to the media module and hence might be lost.

Switching from TinyMCE to CKEditor

Drupal 8 is set to use CKEditor; having finally got fed up with TinyMCE, so was I. Even with the upgrades above, I still couldn't get the media browser plugin to work in TinyMCE, which continued to throw Javascript errors of the form 'Cannot read property 'add' of undefined" in Drupal.wysiwyg.editor.init.tinymce'.

The WYSIWYG project makes different editors (in theory) entirely hot-swappable, if you just download the editor project's files into a relevant folder in libraries/. With the caveat below, this was indeed the case. I now have a media browser that works!

Upgrading WYSIWYG

As with Media, WYSIWYG has had no full 7.x release for nearly two years now. A longstanding compatibility problem with CKEditor (reported November 2012, just after WYSIWYG's last 7.x release) arose when the 4.x branch of that third-party project moved its version numbering out of its main Javascript file comments. That meant WYSIWYG could no longer autodetect which version was installed and confirm compatibility. The simplest solution is to use WYSIWYG's 7.x-dev branch, which I'm now doing, and it looks OK so far.


Upgrading Media, File Entity and WYSIWYG ended up straightforward enough. They're all great projects and the simplicity of using them clearly shows the hard work and great, usable functionality inherent in all of them.

I just wish the releases (and their names) for these projects inspired as much confidence as the maintainers and the code arguably deserve: the widespread and longstanding usage of this software ought to speak for itself, but the way the version naming conventions have been implemented lets them down by giving inexperienced developers the fear.