After following the install instructions for both FCKEditor and Image Browser, I've managed to get this up and running to the extent that the Image Browser button shows up on the FCKEditor toolbar, the popup window with my image library, imagecache options, etc., displays properly.

However, once these options are set, clicking "Insert" seems to do nothing at all. I have the plugin folder correctly installed in FCKEditor's plugins, and I've enabled the Image Browser filter at admin/settings/filters and in the settings for FCKEditor. Is there something I'm missing here?

Comments

jseffel’s picture

Sounds like you are running a PHP-version which doesnt support json_encode() ( version < 5.2 I think).

ltbrady’s picture

Yup, looks like it's 5.1.4. Short of convincing my host to upgrade (which is unlikely in the near term), are there any workarounds for this?

ltbrady’s picture

Answered my own question -- posting the workaround here in case anyone else is in the same boat (shared hosting, older version of PHP, unlikely to upgrade soon).

After some searching, I found json_wrapper, which implements json_encode for earlier versions of PHP. You can find a zipped download at http://www.boutell.com/scripts/jsonwrapper.tar.gz. Just install the contents of this directory in the imagebrowser directory, and at the top of imagebrowser.module, insert the following line:

require 'jsonwrapper.php';

Make sure the whole unzipped package is installed, including its subdirectories. And of course, if you need to call json_encode from more than one module, you might want to install this somewhere more central and have the "require" line point there. But you get the picture...

Thanks for a fantastic module to the maintainer, by the way, who I guess is on vacation in Kenya. Well-deserved...

ltbrady’s picture

Status: Active » Closed (fixed)
ppcc’s picture

Hi

I had this problem too, with php 5.2.8, nginx and fcgi.

The problem was to do with the rewrite rules in the nginx config, and hard-coded url query strings in these two files:

modules/imagebrowser/js/imagebrowser.js
modules/fckeditor/plugins/imagebrowser/fckplugin.js

So as a quick workaround, I removed "index.php?q=" from the files.

eg, in imagebrowser.js, change:

/**
 * Call correct API for insert
 */
function ib_insert(fid, preset, link, link_target, styles)
{
  $.getJSON(top.window.Drupal.settings.imagebrowser.basepath + 'index.php?q=imagebrowser/ajax&tag=[ibimage==' + fid + '==' + preset + '==' + link + '==' + link_target + '==' + styles + ']',
  function (data, textStatus) {
    ib_process_insert(data);
  });
}

to

/**
 * Call correct API for insert
 */
function ib_insert(fid, preset, link, link_target, styles)
{
  $.getJSON(top.window.Drupal.settings.imagebrowser.basepath + 'imagebrowser/ajax&tag=[ibimage==' + fid + '==' + preset + '==' + link + '==' + link_target + '==' + styles + ']',
  function (data, textStatus) {
    ib_process_insert(data);
  });
}
k.obrien’s picture

Tried this and still no insert functionality. I'm waiting to hear if PHP can be upgraded on my server. Crossing my fingers!

k.obrien’s picture

Admin won't upgrade PHP until the Linux distribution adds a newer version. Any suggestions for getting this to work with 5.1.6 would be very appreciated. All the functionality in imagebrowser is working (showing thumbnails, uploading and deletion of images, etc) except the ability to insert.

I'm seeing a javascript error as follows when I click the Insert button:

Error: FCK is undefined
Source File: http://nuweb7.neu.edu/edtech_drupal/sites/all/modules/imagebrowser/plugins/ib_fckeditor/ib_fckeditor.js?l
Line: 22

Not sure if that's related to the json_encode problem or if it's a separate issue.

PEpe’s picture

I had the same problem... Problem was setting in Devel module - option "Display memory usage" must be DISABLED
(JS can't parse JSON response, because there was info about memory usage). My working configuration:
jQuery Update 6.x-2.x-dev
jQuery UI 6.x-1.3 !!!! don't forgot download library (i use 1.7.2)
Image Browser 6.x-2.x-dev
Image Browser Plugin - WYSIWYG API 6.x-2.x-dev
Wysiwyg 6.x-2.1 with TinyMCE 3.3

dbassendine’s picture

This can happen if your node/add/* or node/*/edit paths are protected with Secure Pages.

jQuery doesn't like the switch between http:// (imagebrowser/ib_wysiwyg/* path) and https:// (the main node window) and blocks the request for security reasons - thowing an error message:

"Unsafe JavaScript attempt to access frame with URL ..."

As a workaround, I just removed those paths from Secure Pages config.

Cheers, David

Tony Sharpe’s picture

Removing those 2 settings from secure pages as in #9 worked for me.

pameeela’s picture

I got it to work by adding:

*imagebrowser/*
*/imagebrowser/ib_wysiwyg*

To the pages to ignore in Secure Pages. At least that way the node pages are protected some of the time.