Images not showing when Clean URLs are enabled
ddeursen - September 13, 2006 - 13:47
Hi,
I finally managed to get Clean URLs working, then I discoverd most of the header images (and some other gfx) of my website www.meffect.nl is not shown anymore. When I switch back to non-clean URLs, the images are shown again.
Because of usability-reasons and SEO matters I really need to get clean URLs working properly.
Is the someone who has experienced the same behaviour? Or do you have a clou what can be wrong in my configuration?
Any help is appreciated, keep up the good work,
Dennis

HTML source
So paste some of the HTML source. Give us something to work on here!
Where are the images being looked for?
Could be base_url sorta troubles - I'm guessing you built the template with all your images assuming root-relativity.
[img src="images/home/header.gif"]
instead of explicitly :
[img src="/images/home/header.gif"]
Both will work under unclean-urls. but the first one will break if clean-urls start working.
See also the theming guide on how to include $base_url in your template if you need to support subsites.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
I am having the same issue with Clean URL
Same scenerio for me, when enabling clean URL, my images disappear! I google for a bit, i found img_relocator, it says it should fix absolute/relative path. So i installed it, did not work for me. If anyone can get it to work, let me know, the modle is here: http://blog.riff.org/2006_08_20_the_img_relocator_module_for_drupal
My images are still not showing up, for now i have turned off the clean URL, untill a solution is found. The other solution mention below does not seem to be clear to me, i am new to drupal.
Can someone suggest other alternatives? Solutions, ideas? Thanks.
tecito.com
Comunidad Latina en Canada, regístrate ya! Join the growing latin community in Canada.
Relative links - are relative to where you say you are.
You don't need a module, you just need to understand what URLs are.
As I explained above, you shold have added the images with the correct paths in the first place.
Look at the site linked in the OP.
http://www.meffect.nl/?q=node/8 (heh)
Up the top it has an image put in there like so:
<?php<img src="files/img/colum_spacer.jpg" />
?>
which works fine if you are only ever looking for that image relative to the webroot
With dirty URLs, all pages are effectively just thinking they are a version of http://www.meffect.nl/index.php. So they ARE being served from the webroot.
BUT,
If you try to set the URL via clean_urls to http://www.meffect.nl/node/8
then the image is expected to be found at http://www.meffect.nl/node/files/img/colum_spacer.jpg
and it's not.
That can be fixed by correcting the mistake in the HTML code - just one slash at the beginning means 'always start from the top of the site, not from where I'm pretending to be'
<?php<img src="/files/img/colum_spacer.jpg" />
?>
The full story is here but you can probably find a good explanation in an HTML for dummys guide in some tutorial on the net.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
It seems to be working for me.
Because my drupal is install in a subfolder, i have to also type the subfolder name, like so:
/drupal/images/file.jpgthis works if clean URL is enabled.images/file.jpgthis works if clean URL is desabled.Is there a code i can use in the page header so it will automatically add the subfolder as the base? I was thinking about "GLOBASL_URL"(i tried, it did not work) is there such thing as "GLOBALS_SUBFOLDER"? It would eliminate writing the subfolder entirely.
Thanks in advance.
tecito.com
Comunidad Latina en Canada, regístrate ya! Join the growing latin community in Canada.
Site-relative is not absolute
Note that just adding the / in front will make images to site-relative URLs, not absolute ones. For HTML browsers, it doesn't matter. However for RSS aggregators, this is another story entirely: most will not perform URL relocation and the aggregated posts will never have their images shown (drupal planet or planet php are examples of this).
To avoid the problem, actual absolute paths (http://www.example.com/files/image.png) are required, which is a maintenance nightmare if/when sites move. Or img_relocator can work around the problem.
If you have problems with the module, can you contact me directly ? The module has no project page because I still hope to see a more generic solution, but I maintain it.
can i suggest $content .=
can i suggest
$content .= 'var base_path = "'.base_path().'";';
EDIT: I really should stop bumping into old threads :)
--------------------------
Drupalize the world!
Problem solved by using starting /
Thanks for your input,
I used blocks within my headers, in the block definition I refered to the header image using a path not starting with the /.
I am always trying keeping your paths relative as possible, but with rewriting it is obviously a different story.
Thanks again for your help,
Dennis
You should use the build-in
You should use the build-in image theming function ( http://api.drupal.org/api/4.7/function/theme_image ):
<?phpecho theme('image', 'images/myimage.jpg');
?>