Hi, I used filefield insert and FCKeditor (over wysiwyg) and resize filter to insert some images on a development site which forked fine. After moving to a life site (only the domain changed: domain.dev -> domain.de) all links are broken which is OK since I read that ff_insert is only a easy way to but the correct link into an textfield and not careing about the data behind.
But even after I changed all image links in the db (via search an edit which was a pain) non of the images showed up. I checked the image src in FCK and it showed the correct path. And the images are in the correct folder and correctly named. Any hint why this went wrong. Image links are broken and even the files below the textfield (where you select an upload the images) are empty.
Thx for the help
Smartypants
Comments
Comment #1
quicksketchFor the most part, you cannot, ever change the file directory. You've hit the problem on two fronts, one, the file fields themselves loose their value because the paths are not updated in the "files" database table. However, even if you fix that, the paths need to be updated in all the settings throughout Drupal (such as default user picture, logo image, etc.), and also in all the content you've ever posted to the site, which could be stored in the node body or in any other CCK text field you've added.
To work around this problem and prevent it from ever occurring, you should probably use symlinks for your files directory and put it at a location that would never change, such as "sites/domain/files", rather than "domain.com" or "domain.net". Then make a symlink from the "never-changes" directory to the name that might change. In your case, you have the option of either trying to update every reference to the old file in the database (try taking a database dump then searching it for the file directory path), or make a symlink from the old path to the new one, so that new files will be stored and referenced from the new location, while the old paths will just be symlinked to the new one.
Comment #2
mattyoung commentedsubscribe...
I'm curious why even store the {sites/DOMAIN/files} part anywhere. How about have that dynamically figure out or be changed easily? Everything should be keyed of of
file_directory_path()ideally. As is, Drupal sites are not portable: paths are hardcoded to a specific multisite location. At least modules and themes paths can be fixed by visiting admin/build/modules. It would be nice if files paths can be fixed up the same way.Comment #3
quicksketchmattyoung: The inclusion of the filepath in the files table has always been a big mistake, but that's the way it has been for several releases of Drupal (but has been fixed in Drupal 7). As it is, I'd recommend keeping your files directory in a location that never changes. I usually make a directory at "sites/example/files" for an example.com domain, then make a symlink from "sites/example.com" to "sites/example". So the files are always stored in the "real" directory at "sites/example/files", while the symlink makes Drupal happy when doing it's settings.php search.
Ah, I just realized I already stated this solution above. Until Drupal 7, this is the best solution other than manually updating your database with the new file paths. The Pathologic module might be able to help temporarily in moving from dev to live, but generally it's best to avoid the problem entirely and never change your files directory.
Comment #4
mattyoung commented>I usually make a directory at "sites/example/files" for an example.com domain, then make a symlink from "sites/example.com" to "sites/example"
Ah ha, so I did this with a slight change. I have lots of multi-sites and don't want my sites directory to be littered with twice the directories. So I create a 'sites/files' directory and under that, have one directory each for every domain to hold files:
sites/files/example-A
sites/files/example-B
...
then I make symlinks:
sites/example-A-devel.com/files---> ../files/example-A
sites/example-B-devel.com/files---> ../files/example-B
and use the files directory 'sites/files/example-A' in place of 'sites/example-A.com/files'
this should work?
I wonder if I should turn off write permission to sites/files/example-A? Drupal turn off write permission to the sites/domain directory.
Comment #5
quicksketchYes that should work, the important thing is that the files directory is never physically moved. You should not disable write permissions to the file directory. Drupal disables write access to only the root of "sites/domain", but leaves write permissions on for the files directory, since it wouldn't be able to write any files otherwise.
Comment #6
mattyoung commentedthank you!
Comment #7
quicksketch