Following the migration of my site from a multisite setup to its own "normal" setup, images aren't showing - they've all been loaded to http://mysite.com/sites/default/files/images/ but the path coming up on the site is http://mysite.com/sites/default/files/sites/mysite.com/files/images/

The default image path set in admin/settings/image is unchanged from "images".

Is the path problem something I need to reset in settings.php or .htaccess? I've looked through these but can't see anything obvious to edit or (un)comment etc. Any help much appreciated.

Comments

sillygwailo’s picture

Take a look at the database and see if the file paths are stored with the domain. Run the following query to see what they're stored as:

SELECT fid, filename, filepath FROM files;

If they're stored with the wrong domain (or rather in your case, with a domain at all), you can replace them with a query like this one (with your domain, of course).

Backup your database before you do this, in case you introduce a typo or something.

UPDATE files SET filepath = REPLACE(filepath, 'mysite.com', 'default') WHERE filepath LIKE '%mysite.com%';

You will probably need to clear the cache after this step.

(Username formerly my full name, Richard Eriksson.)

thoughtcat’s picture

Hi Richard,

Many thanks for your help :) When I ran your first query I did indeed see "mysite.com" in 442 rows (I think that's the right terminilogy - sorry, I am a real MySQL noob).

I then tried your second query but got the message "You have to choose at least one column to display" - can you tell me what that should be? My guess is "files, filepath" but am not sure.

Thanks :)

sillygwailo’s picture

I'm guessing you're using phpMyAdmin (references to it come up when I search for the error message). I don't know how to trigger that error, but some people have said that it comes as the result of pasting a query into the wrong field. In the version of phpMyAdmin I have, clicking on the database, then the "SQL" tab, then pasting in the query seems to work for me without that error.

(Username formerly my full name, Richard Eriksson.)

thoughtcat’s picture

Thanks for that, yes, this time I tried clicking "SQL" rather than "query" and it worked first time. When I replaced the site domain string with "default" I got "439 rows affected".

The images haven't reappeared though, even after flushing all caches. I've now got Image Assist code appearing in place of images added using Image Assist. The Image module is saying it's "missing" even though the code is clearly present on the server (see my separate post at http://drupal.org/node/1322596). I turned off some modules last night due to a performance problem, including ImageMagick Advanced Options because this wasn't being used as far as I could see (in admin/settings/image-toolkit I've got the GD2 toolkit selected) so I don't know if that had anything to do with it, but this has had the effect of disabling Image Assist, Image Attach and other dependent modules.

thoughtcat’s picture

Attached images ARE now showing up. Silly problem with Image module due to missing .info file in the site migration. Thanks again for your help :)

Vasu’s picture

Richard you are a life saver. Thank u.

alar’s picture

My issue is the reverse moving from single setup to multi. The db update did the trick!

Run the SQL statement:
update `files` set filepath = replace(filepath,'sites/default/files','sites/mysite.localhost/files');
- or -
update `files` set filepath = replace(filepath,'sites/default/files/images','sites/mysite.localhost/files/images');

And then clear the cache to rebuild the images. :)

When I move back to single site I'll just put them back...
update `files` set filepath = replace(filepath,'sites/mysite.localhost/files/images','sites/default/files/images');