Jump to content

Display an image


mboehler3

Recommended Posts

Hi, I am very very new to PHP and I am trying to build my own Wordpress template from HTML code. I've created the header.php and I'm trying to display an image I have inside my images folder. I believe I need to use an echo statement, but I may be wrong. Can someone please offer me some help? I appreciate it very much, thank you in advance.

Link to comment
Share on other sites

Nothing special about displaying an image, just use the simple img html tag..if you want to echo it out using php then:<?phpecho "<img src='prettypicture.jpg' alt='' />";?>
Weird, I tried using this code:
<?php echo "<img src='images/get-started.jpg' alt='Get Started' />"; ?>

and the image failed to display. Is there something else I can use?

Link to comment
Share on other sites

Path names can be tricky in Wordpress. Where exactly is your images directory with respect to your wordpress directory?What your path is telling the browser currently is that 'images' is a directory at the same level as 'index.php' -- if in fact it is above your wordpress directory, or if it is in 'wp-includes' or one of your theme directories (etc.), the browser will be looking in the wrong place.The situation is more complicated if you are using URL-rewriting in an .htaccess file.

Link to comment
Share on other sites

Path names can be tricky in Wordpress. Where exactly is your images directory with respect to your wordpress directory?What your path is telling the browser currently is that 'images' is a directory at the same level as 'index.php' -- if in fact it is above your wordpress directory, or if it is in 'wp-includes' or one of your theme directories (etc.), the browser will be looking in the wrong place.The situation is more complicated if you are using URL-rewriting in an .htaccess file.
I have my images folder inside of my current theme's folder. It still thinks the images directory is at the same level as index.php, even though the path has "images/" in front of it? Since the images folder is in the theme folder (wp-content/themes/[theme name]), how do I tell Wordpress that?Thanks in advance for your help.
Link to comment
Share on other sites

wp-content/themes/[theme name]/images/get-started.jpgIf that's where it is, that's how to find it.You could of course create an images directory at the same level as your index file. It would change your organizational plan, but it's doable.

Link to comment
Share on other sites

wp-content/themes/[theme name]/images/get-started.jpgIf that's where it is, that's how to find it.You could of course create an images directory at the same level as your index file. It would change your organizational plan, but it's doable.
Thanks for your help, when I have this code in my header:
<?php echo "<img src='wp-content/themes/warehouse/images/get-started.jpg' alt='Get Started' />"; ?>

the image shows on my homepage (localhost/wordpress/)... however when I go to another page, localhost/wordpress/page/ for example, the image does not display, but the ALT tag does show. Do you know why this is?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...