Drupal 6 Multi-Site...Where Are My Images?

If you convert a Drupal site to a multi-site configuration, you will very likely notice a disturbing side-effect: your images no longer appear!

In a standard configuration, your images will likely be in the sites/default/files folder. Let's say that we have created a multi-site configuration, and our original domain is mysite. So, now we will have a directory of sites/mysite/files, to which we will move the images, and herein lies our problem.

Do Not Change the Files Directory Location on an Active Site

That is a primary rule, but, of course, changing to a multi-site configuration necessitates the sites/default/files directory of each site being moved to directory such as sites/mysite2/files, sites/mysite3/files, etc. The reason for the rule, and the reason for the problem, is that in Drupal 6, the file locations are kept in the database. Moving the files does not change the location already recorded for them in the database.

The result is that, for example, when imagecache creates a link for our file, what used to be

sites/default/files/images/image1.jpg

has morphed into the worthless

sites/mysite/files/sites/default/files/images/image1.jpg

The easiest way to repair this is:

  • export the files table from the database
  • use a text editor to alter the URL's (replace applicable occurrences of default with mysite, where mysite is your site name)
  • import the repaired table

 

You may find that the same action is required with the imagemenu table if you are using that module.

Remember to clear both your Drupal cache (admin/settings/performance) and your browser cache.


Type:
Tip
Tags:
D6
image