Using CiviCRM 5.7.2 with Drupal 7.61, when editing a newsletter in CiviMail, the image browser always points me to


no matter what I configure as the directory path for "Image Directory" at


I've tried relative path ([cms.root]/sites/default/files/uploads), absolute path, and absolute path via settings override in civicrm.settings.php; all to no avail.

[added to clarify in response to @Chris Burgess' comment]: The setting does stick, as in it shows up as entered in the form after a reload; and when I tried settings override via civicrm.settings.php, that setting showed up instead and made the form field uneditable. Still, whatever shows up there does not seem to have any impact on where the image browser takes me.

I double- and triple-checked permissions and they are fine; we're also using the same directory with ckEditor and IMCE in Drupal with no problems.

Not sure if I'm missing something, but isn't that the correct setting for what I want to do? Either way, is there a way to point the image browser to our general image path in the drupal files directory?

Many thanks in advance for any advice!

Update: The image browser window shows the following URL:


so I poked around a bit in the kcfinder directory. There's a config.php, but it appears that the settings in there are also ignored.

So I took more desperate measures:

cd $drupaldir/sites/all/modules/civicrm/persist/contribute
mv images images.HOLD; ln -s ../../../../../default/files/uploads images

Now it shows me the correct directory (though with the wrong name), but whatever I try to do, I get a "warning" dialog stating "unknown error". Well, was worth a try.

Anything else I could try to get this to work?

  • When you set the value in the CiviCRM UI, does the change get saved so that you see the changed value when reloading the admin form you set the value in? If not, it's possible that your site has a settings override in place - see this link for docs on settings overrides – Chris Burgess Nov 26 '18 at 5:32
  • Hi Chris, thanks for the suggestion and yes, the setting does stick. I've also tried settings override and had it show up alright on the configuration page. I'll amend my question, thanks again. – rjoz Nov 26 '18 at 5:35

Ok, I've worked it out. And it turns out that there is a location where CKEditor settings can be configured, namely at civicrm/admin/ckeditor?preset=default. (Through the GUI it's at "Administer" -> "System Settings" -> "Display Preferences", then click the "Configure CKEditor" button towards the bottom.)

There are a few hitches on the way and perhaps this comes in useful for someone else down the track:

  • the image directory must be called images for the CiviMail browser to work with it;
  • the image upload directory setting in CiviCRM needs to point to the parent directory of that images dir; in my case it is [cms.root]/sites/default/files/;
  • the setting to override in the CKEditor settings is ImageUploadURL, which also needs to point at the parent dir of images. A local path works - I used /sites/default/files.
  • turns out that that alone didn't do the trick (I could browse the correct directory, but the browser would then return the wrong URL string); I also needed to override the setting in civicrm.settings.php like so (look for $civicrm_setting to find the examples):

    $civicrm_setting['URL Preferences']['imageUploadURL'] = '/sites/default/files';

And that's it!

Now for this naming requirement.

In my case, we have been keeping all our images organised in a directory called uploads, and the image browser clearly had a problem with symbolic links. So what I did is

mv uploads images
ln -s images uploads

Aka rename uploads to images, then create a symbolic link named uploads. Then reconfigure IMCE in Drupal to now use the images folder. (It seemed to keep working just fine with the symbolic link, but we want to keep things clean.)

NB: In my case, the site is hosted on a cPanel with no ssh access, so I did the renaming through the GUI and then created a cronjob to run the second command (here at 19:45h, and don't forget to delete it again) like so:

45  19  *   *   *   ln -s images /path/to/drupal/sites/default/files/uploads

As a result, all images now live in $drupaldir/sites/default/files/images and both, IMCE in Drupal, and kceditor/ckeditor/whateveritis in CiviMail, now work with it, referencing the same files. Yay!

Meanwhile, Apache seems happy to resolve across the symlink, hence all existing URLs keep working, though it'd be nice to clean them up over time.

(Not a straight-forward search/replace through the database, unfortunately, as the two strings have different lengths. If they were the same length, that'd be simple.)

  • good sleuthing. when you get more Reputation you should be able to Accept (green tick) your own answer – petednz - fuzion Nov 26 '18 at 18:52
  • 1
    Thanks @petednz-fuzion 😊 The message I got when trying to accept my answer was that I'd need to wait 24 hours before I can do that. – rjoz Nov 27 '18 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.