Template image path
How would you set the image path when including templates? The goal is to allow the designer to open the html template, make their edits and save and the php code would bring it in and display it. The problem is images, take this html template:
Now bringing up the html template in an html editor shows the image correctly but bringing it into the root of the folder in php shows a broken image:
Hi there! <img border="0" src="../images/smiley.gif">
Well the image folder is in the root of the php file so the image path is invalid. I cant have the editors use the full url path because the domain might be different. Do I have to write a script that rewrites all relative paths with the absolute path when building the template on the php side?
can be rewritten as /image/folder/image.ext
I always use root relative paths always.
So your saying that if a designer wanted to add an image to template.html through Frontpage they would need to add the image and then turn the relative path to the root relative path in the html code itself correct? Because normally in a WYSIWYG if I added an image from the image folder it would look like:
Originally Posted by logic_earth
What your saying is the designer would need to manually change the code to look like:
<img border="0" src="images/someimage.gif">
<img border="0" src="/templates/images/someimage.gif">
Yes. if you did relative to the file thats in the template folder but you are including it in index.php outside of the template folder those path no longer work.
Also what happens when you want to use the same template seven folders up? http://example.com/f1/f2/f3/f4/f5/f6/f7/file.ext but with root relative urls for paths. /templates/images/someimage.gif goes straight to the file.