I'm new to Drupal, so my wording and knowledge might be off. My problem is that I'm using some images for the design of my site and they are not showing up. I'm using Dev Desktop and Drupal 7. The ones in my css are showing up, but not the ones in the page.tpl.php are not. Is there a special location where I need to put my image folder or path that I need to create. Right now I have it in the sites/all/themes/myTheme folder.

Comments

Dollowmite’s picture

<blockquote><div id="container">
                       	<div id="ndsLogo">
								<?php if ($logo): ?>
                                        <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
                                        		<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
                                        </a>
                                <?php endif; ?>
                        </div>
                        <div id="ribbon2"><img src="images/ribbon2.png" width="30" height="321" /></div>
                        <div id="ribbon3"><img src="images/ribbon3.png" width="30" height="321" /></div>
						<div id="pageWrapper">

ribbon2 and ribbon3 are two explains

nevets’s picture

The path needs to be relative to the site root or instead of using an img tag you could use css applied to #ribbon2 and #ribbon3, setting, height, width and background image

Dollowmite’s picture

Isn't that a relative path? An absolute path has http://, right?

My page.tpl.php is at the root of my custom theme (Located in sites/all/themes/) along with my images folder. So wouldn't my relative path be: images/ribbon2.png? or do you mean ./images/ribbon2.png, because I tried that, too. I can't apply them to my css, because they are going to be links to other sites.

Thanks for helping me.

nevets’s picture

Without a leading '/' src is relative to the current path being viewed. So for example if you are on 'node/123', the source path becomes '/node/123/images/ribbon2.png'. If they work for what you are doing css background images have the advantage of being relative to the css file. Using an image tag you would want something like

<?php
  global $theme_path;
  global $base_path;
?>

<img src="<?php print $base_path . $theme_path . '/images/ribbon3.png';?>" width="30" height="321" />

Dollowmite’s picture

Sorry you just lost me. How does

<img src="<?php print $base_path . $theme_path . '/images/ribbon3.png';?>" width="30" height="321" />

find the images folder, because that is the same path. Plus I don't understand what this is, because I know vary little php.

<?php
  global $theme_path;
  global $base_path;
?>

thanks again for your help

nevets’s picture

$theme_path and $base_path are Drupal global variables so they need to be declared as such.

The path you have, 'images/ribbon3.png', is relative to the current url/path you are viewing, not the theme directory. Adding $base_path . $theme_path . '/ makes the path complete so it is relative to the site root an in the theme directory.

Dollowmite’s picture

Thank you. It worked

adams.garfield’s picture

Thnaks for the solution nevets. I fanally got it working!!!! :)