I'm muddling along making a custom theme. My partner and I wanted to use the image header module for our site but the ImageField cck module is not up to date for 6.x. Anyway, so I thought I could use the <img src /> tag to link out to an image in my image folder. However, this is not working at all. I made a page-node-1.tpl.php file and wanted a different header on that from the one on my front page and it totally did not work at all. I know that my site is reading that page-node-1-.tpl.php, but it will not load any images I linked to using the <img src /> tag. Why is this?

If it helps, I am working on a localhost using xxamp.

Comments

vm’s picture

to help, we will need to know where the image is being stored?
and exactly how you are referencing it with an img tag.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

beckyjohnson’s picture

Ok, well, my image is being stored in a couple of folders so the img tag looks like this, with a div that handles positioning around it:

<div id="banner_medium">
		<img src="images/headers/medium/events01.jpg" width="970" height="200" border="0" />
	</div>

I have a block called image banner which defines this area but I'm not sure what to do with it....I was originally going to use my image banner region in conjunction with the header image module but a module it appears to depend on is not up to date yet.

Interestingly, I cannot even get my site logo showing up using the page found at themes > configure. I thought that had to do with how my localhost is set up though.
Becky

vm’s picture

and the images folder is stored where ? at the drupal root ? in the theme folder ?

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

beckyjohnson’s picture

The image folder is stored in xxampp>htdocs>drupal6>sites>all>themes>custom>name_of_my_site folder. It is in the same folder as my .info file, my screenshot and all of my page.tpl.php files.

Becky

Chippe’s picture

How about "sites/all/themes/custom/name_of_my_site/events01.jpg" ?

Since thats where you say your picture is located.

beckyjohnson’s picture

yes, I could try that but if i have my images folder and all of it's sub directories in the same folder as my page.tpl.php file why would i need to be that specific? Why am I suddenly not able to link things relatively?

Chippe’s picture

Im using xampp too and my theme is located in the theme folder, it's where I think it should be stored:
xampp\htdocs\drupal6\themes\my_theme

In all themes there is a folder called img. If you put a picture named pic.jpg in that folder the link would look like this:

<div id="banner_medium">
 <img src="img/pic.jpg"/>
</div>

For you it should look something like this:

<div id="banner_medium">
 <img src="sites/all/themes/custom/name_of_my_site/events01.jpg"/>
</div>
beckyjohnson’s picture

I couldn't see your code. You forgot to wrap it in code tags.

Chippe’s picture

here it goes again:
Im using xampp too and my theme is located in the theme folder, it's where I think it should be stored:
xampp\htdocs\drupal6\themes\my_theme

In all themes there is a folder called img. If you put a picture named pic.jpg in that folder the link would look like this:

<div id="banner_medium">
 <img src="img/pic.jpg"/>
</div>

For you it should look something like this:

<div id="banner_medium">
 <img src="sites/all/themes/custom/name_of_my_site/events01.jpg"/>
</div>
yelvington’s picture

beckyjohnson’s picture

I don't understand what I'm looking at on that link. Could you explain a tad please?

Becky

vm’s picture

The best way to explain it , is to have you seek out an example: Grab a theme that uses images in it, inspect the way these images are called into the tpl.php

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Chippe’s picture

I don't get it either. Please explain what to do.

cog.rusty’s picture

He means something like:

<div id="banner_medium">
<img src="<?php print base_path() . path_to_theme() . '/' . 'images/headers/medium/events01.jpg'; ?>" width="970" height="200" border="0" />
</div>
beckyjohnson’s picture

oh! interesting. Do I have to do anything special to the path_to_theme() or base_path() first?

Becky

update: WHoo hoo! It worked!

Thank you!
And thanks to everyone else who tried to help out!

Chippe’s picture

Thanks!

supriyarajgopal’s picture

Hello,

Thank you cog.rusty...I was facing the exact same problem and your solution worked for me :) :)

Regards,
Supriya Rajgopal

beckyjohnson’s picture

But my images folder is in my name_of_my_site folder along with my page.tpl.php. So why can't I say <img src "images/name_of_image" />? I even tried putting all the images on the top level with my page files and going <img src="name_of_image" /> and it doesn't work.

Chippe’s picture

I have no idea but it just doesnt work as you say but I also have very limited skills however I often manage to solve my problems.

It will work if you put the div tags in your php-file but the path to the picture in your css-file.

in style.css:

.divtag { background: url(images/events01.jpg); }

cog.rusty’s picture

Relative links are resolved by the user's browser, using the path of the page the user is on.

If you are using clean URLs, even the suggested link might fail if the user is on a page like node/35, for example. It would become:
node/35/sites/all/themes/custom/name_of_my_site/events01.jpg
In that case you would need a front slash too.

beckyjohnson’s picture

yeah.. that makes sense but I'm trying to link to an image outside of the drupal database. The images are not in a database they are just in a folder so....

cog.rusty’s picture

Yes, I see... but the browser doesn't care where things comes from, only what is displayed.