A site I administer uses the openWYSIWYG rich text editor module as the default input format for most users. Like other rich text editors, openWYSIWYG makes it possible for anyone to add styles and colors to their posts, including tables, images, links and more.

The openWYSIWYG interface

screenshot_2011-01-08 1.jpg


Most of the site’s users prefer the ease of use of a rich text editor but for those of us that need more control over the HTML than rich text editors provide, it is possible to shut it the editor off for specific users or for specific types of nodes. It is also possible to shut it off by simply using Safari, since the module is not yet built to work with Safari.

My preferred module for uploading images when openWYSIWYG is not active is Imagepicker, because of its simplicity and reliability.

The Imagepicker interface
2011-01-08_16-04-00.jpg

Imagepicker allows you to select an image from a collection of uploaded files, then insert it into the text area. But a problem arises when trying to use imagepicker when open WYSIWYG is installed, even when the editor is not being displayed, because certain key variables are still in “openWYSIWYG” mode, and that fools Imagepicker into thinking the editor is active. Because of this, Imagepicker cannot find the text editing area and the “insert image” button stops working, because it is looking for an element that does not exist on the page.

Fortunately, it’s fairly easy to do a quick fix for this, so it will at least work in Safari.

In the imagepicker module folder, find imagepicker_iframe.js

Search near line 172 for

else if (isWysiwyg == 'yes') {
        //inst = 'edit-body';
       inst = win.Drupal.wysiwyg.activeId;
      }

and change it to:

 else if (isWysiwyg == 'yes') {
        //inst = 'edit-body';
       // inst = win.Drupal.wysiwyg.activeId;
         inst = 'win.Drupal.edit-body';
      }