0
votes

I start with Drupal and I have read some of topics about my problem but I didn't found the solution. My problem is the following :

On my website (for the moment in localhost) I use Clean URLS module. The problem is when I enable this module and when I use the relative path of my files, my pictures or links don't work.

For example : src="./sites/default/files/styles/large/public/add_tool_version.png".My pictures are not visibles.. I don't know why this module doesn't work with the relative path.

But when I disable the module, the link is works fine. Please, can an you help me ? Do you have any solution to fix it ?

Thanks in advance for your answers

2
I test with the path :../sites/default/files/styles/large/public/add_tool_version.png and it works! But now, I don't have the preview the I edit the link. Do you know why? Thanks in advance - InsRg

2 Answers

0
votes

Try using absolute paths. In you case with image it would be like: src="/sites/default/files/styles/large/public/add_tool_version.png", without dot.

This absolute path will always refers to that image instead of relative path - it depends on you current directory or page.

0
votes

The problem with clean urls is the way browsers read urls and interpret them as directions in a file directory. Lets say you are at http://www.example.com/?q=node/11, or, with clean urls enabled, at http://www.example.com/node/11.

When enabeling clean urls, and putting a link with a source into some node, your browser will search for your files in the folder that is specified in your url. Thus, when you declare the source to be sites/default/files/styles/large/public/add_tool_version.png and are on the url http://www.example.com/node/11, then the browser will look for the file in the directory node/11/sites/default/files/styles/large/public/. Usually this would work, but in drupal, there actually is no such folder. All drupal pages are just versions of the index.php in your base-directory. In drupal, the url doesn't have anything to do with file structure - unfortunately, the average browser doesn't know that.

Without clean urls, however, your browser will recognize the url as a combination of a base path (www.example.com) and a query (?q=node/11). It will therefore look for your file starting from the directory specified in your base path.

If you still want to have your relative paths working with clean urls enabled, you can use the function base_path() in front of your actual source.