By ajlowndes on
Hi I have my images which will appear on the front page in sites/default/files/. I also have node/1 set to in administer>site configuration>site information. If i insert an image into my node/1 body using the drupal "edit page" like so:
<img src="sites/default/files/background.png">
then it will appear on the front page, but it not until I refresh. This is because before I refresh I am on "http://localhost/mcc/node/1" and after I refresh I am on "http://localhost/mcc"
I guess this is because of the relative link, but I don't know where I should put my pictures instead (i can move them all if there is a better folder for them) or where the link should point to.
any help appreciated.
Comments
try (note the forward slash
try (note the forward slash before 'sites')
this will cause the path to be relative to your root directory and will therefore be valid from any page/path on your site it's called from.
no that didn't work, the
no that didn't work, the image doesn't show at all on any page with that slash in there...
Then 'sites' is not the in
Then 'sites' is not the in the root folder. If your drupal install is in something like drupal6/sites/... you will have to make your img path drupal6/sites/...
yeah that worked - my drupal
yeah that worked - my drupal install is in "mcc" so the link was "/mcc/sites/default/files".
But how come then I have to go to "http://localhost/mcc" to see my site? i.e it doesn't display anything when I go to "http://localhost", but the pictures folder is referenced from there. What happens when I move my site up to a server and I want the site to display without typing in /mcc? that is confusing.
Yes, you will have to change
Yes, you will have to change your hard-coded paths after you move your site. The alternitive is to use a combo of php, $base_url variable, and setting the base url in your settings.php.
If you only have a minimal amount of img paths, it is probably easier to make note of them and simply remove the folder from the beginning of the path after you move the site.