Page 1 of 1

php extension and images

Posted: Sat Jul 16, 2011 2:47 pm
by atomic.argonaut
Hi. I didnt really know whether to post this in general or in the area specific to code based questions but I'm trying to create a wordpress theme for a simple page with little knowledge of php. I'm having difficulty getting images to show with the standard src tag when the file is saved under a .php format but notice that when the same file is saved under .html the same images show up. Can anyone help me out? thanks!

Re: php extension and images

Posted: Sat Jul 16, 2011 2:59 pm
by social_experiment
Do you have any code to paste? For a php script to 'work' it has to be on a server that has php installed or the code wont be parsed as php.

Re: php extension and images

Posted: Sun Jul 17, 2011 6:50 pm
by atomic.argonaut
[syntax]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head profile="http://gmpg.org/xfn/11">



<title><?php bloginfo('style.css'); ?><?php wp_title(); ?

></title>



<meta http-equiv="Content-Type" content="<?php bloginfo

('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<meta name="generator" content="WordPress <?php bloginfo

('version'); ?>" /> <!-- leave this for stats please -->



<link rel="stylesheet" href="<?php bloginfo

('stylesheet_url'); ?>" type="text/css" media="screen" />

<link rel="alternate" type="application/rss+xml" title="RSS

2.0" href="<?php bloginfo('rss2_url'); ?>" />

<link rel="alternate" type="text/xml" title="RSS .92"

href="<?php bloginfo('rss_url'); ?>" />

<link rel="alternate" type="application/atom+xml" title="Atom

0.3" href="<?php bloginfo('atom_url'); ?>" />

<link rel="pingback" href="<?php bloginfo('pingback_url'); ?

>" />



<?php wp_get_archives('type=monthly&format=link'); ?>

<?php //comments_popup_script(); // off by default ?>

<?php wp_head(); ?>

</head>

<body>

<img src="localhost/wordpress/wordpress/htdocs/wp-

content=themes/tutorial/banner.jpg">



<h3><span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span></h3>

<h1><a href="<?php bloginfo('url') ?>"><?php bloginfo('name') ?></a>
</h1>
<?php bloginfo('description'); ?>
<img src="banner.jpg">
</body>

</html>
[/syntax]

theres the code. as far as the server being installed, ive xampp running and developing everything locally. wordpress itself works fine.

Re: php extension and images

Posted: Mon Jul 18, 2011 1:35 am
by social_experiment
Are the images placed correctly in accordance with their src attribute paths? The second img tag indicates that the image (banner.jpg) should be located in the root folder. It's also good practise to add width, height and alt to img tags.

Re: php extension and images

Posted: Mon Jul 18, 2011 7:04 pm
by beetree
If your PHP script simply is opening a image file, reading the data and then "echoing" it in the PHP script, you also need to add some headers if I'm not mistaken. /beetree