By offal on
I have set up a drupal site on my home computer at http://localhost/drupal/ and have duplicated this installation at a live site at the top level at www.mysite.org (less the drupal sub-directory). In one of my blocks I have used FCKeditor to place an image, which on the local site has it's link at /drupal/files/image/picture.png. Now because on my live site there is no 'drupal' sub-directory, I have to remove the /drupal from the link. Likewise, it should be possible to remove the /drupal from the link on my local site. This has worked on all other images and links on my local site, but for some reason it is not working in the block. Why is this so?
Comments
relative paths work fine for
relative paths work fine for me in this situation. So I always start image references as files/subdirectory/filename rather than /file_system_root/files/subdirectory/filename
Also, on v5 avoid using sites/example.com/files as the file root for your site, otherwise you can end up with a lot of links to migrate when you cut over to a production server.
Not sure if I understand correctly
Thanks so much for helping out. I'm just not sure that I understand your reply correctly. Please check if I've got it right.
You are saying that using the path files/image/picture.png instead of /drupal/files/image/picture.png is the right thing to do? Do I need a leading forward slash (/) before the files/image/picture.png? (so it would be /files/image/picture.png)
on v5 avoid using sites/example.com/files as the file root for your site, otherwise you can end up with a lot of links to migrate when you cut over to a production server.Are you saying that placing my drupal installation in the top level on my live site is the right thing to do, rather than placing it in a 'drupal' subdirectory?
Are you further saying that I should do the same on my local server to avoid migration problems? If so, then how can I have multiple sites on my localhost server and not end up with a mess? At present they are separated in subdirectories, but without these all my sites' folders and files would be in the same directory (top level of localhost) wouldn't they? Is there a way around this?
Taking these one at a
Taking these one at a time:
1) For me, I can use the path "files/image/picture.png" successfully. But I should point out I'm using URL aliases for all the pages where I have an image so the relative path is always correct. It might not work with unaliased URLs so in that case, including the leading slash should be fine: "/files/image/picture.png"
2) The handbook explains the purpose and layout of sites/example.com and sites/all (http://drupal.org/node/276). Read the paragraph starting "The /files directory is usually best placed...". BUT if you have a test site (on testdomain.com, say) then sites/testdomain.com/files will become sites/realdomain.com/files when you move to production and that'll mess up any file / image links. So what I do now is put all files in files/xxx/ under the drupal installation folder so the pointers don't mess up between the test site and the production site. xxx is a shorthand for the site so that in my multisite setups each site has its own subdirectory. (Crell wrote something on this but I can't find the posting.)
3) You can place your drupal installation either in a /drupal subdirectory or at root level. In my experience migration from test to production is a bit easier if it's at root level. But the next question is probably the important one...
4) I'm not clear how your localhost is configured. Perhaps you have a few different versions of drupal (4.7, 5.1) installed on localhost. Here's a discussion on options for setting up this: http://drupal.org/node/106763 (see CogRusty's input in particular). Alternatively, you may want to get your localhost behaving even more like your production environment. It's pretty handy to have a localhost set up in a way that all the URLs are exactly as they'll be in the hosted environment. It means fiddling with your hosts file and with your apache configuration but it's not too complicated. You could look at the sort of stuff that's described here: http://drupal.org/node/112308
I hope some of this helps.
That makes it a lot more
That makes it a lot more clear now. I will chew on some of that information and check out the links you provided.
I also use aliased URLs so I seem to be doing the right thing there.
Thanks again for your help. I'll post again if I don't have any luck.
Ok, I seem to have the link
Ok, I seem to have the link sorted out. It's now the same on both my local computer (localhost) and the live site by making the link to the image files/image/picture.png.
However, three strange things happen:
1. The image does not show when I am on some of the admin pages. For example, it disappears when I am at admin/build/block, and likewise when I edit the very block that contains the image, it doesn't even show in the FCKeditor block body field. A placeholder is displayed instead. Perhaps it's an FCKeditor thing?
2. The image also disappears when the user (admin or other) goes to the 'my account' page (for example /user/1). So when a user logs in, they won't see the picture until they go to a different page, since 'my account' is default after logging in.
3. I have set up a menu item called 'home' linked to node/1 (default home page). The image disappears when I use that particular menu button. However, the image is present when the site starts up (mywebsite.org) which is also, as far as I know, the default front page at the same node. It is also present when I click the site logo in the top bar, which takes me to the home page.
I could of course link the menu 'home' button to 'mywebsite.org'. This works on the live site, but on my localhost it will link me to the live site instead of the home page of my local test installation. Inconvenient when migrating too!
What's going on? Is it because I'm using aliased URLs elsewhere on the site?
could be that you need that
could be that you need that leading slash after all. If you're not on a top-level page the ling 'files/image/...' will be relative to the existing path. So if you're on node/1 then it'll be looking in node/1/files/image/...' See if that resolves the issue for you.
Yes, using the leading slash
Yes, using the leading slash worked on my live site and fixed all those issues - thanks for that.
However, on my local test site it does not work. By using the leading slash the image has now disappeared altogether - it doesn't show no matter which page is open.
Perhaps double-check the
Perhaps double-check the settings of your file system path are the same on you local installation and your hosted installation:
Home » administer » Site configuration » File system
If they're both identical I'm not sure what could be causing the difficulty.
Both sites have identical
Both sites have identical paths: in the field titled "file system path:" it says 'files'.
Thanks for trying though. I'll keep checking here to see if someone perhaps knows a solution.
Adding logo in locally hosed site
This is for a locally hosted development.
If you upload an image, it adds the image to (the root of) your files folder and displays the image path.
This is displayed as: sites/default/files/theme-name_logo.jpg
(note: 'theme-name' is the name of the theme being used.)
To test the path works without uploading an image:
I am organizing my images so they are placed in an 'images' folder within a folder with the name of the theme I am using. I then added the path: sites/default/files/theme-name/images/logo.jpg
The logo appears in all pages - I have not put this live yet. This also works for the favicon.