I am doing a WordPress theme that uses a php random image file. I want to know how to adapt this code to WordPress so I can use the bloginfo for the paths to the url and image folder instead of hard coding them in.
I am currently using
PHP Code:
<?php
$img_rand 
= array(
   
=> array(
        
'img' => 'image5.jpg'// Add file name, type, even path if needed
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),                              
   
=> array(
        
'img' => 'image9.jpg',
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),
   
=> array(
        
'img' => 'image11.jpg',
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),
);
?>
<?php
$img 
array_rand($img_rand);
echo(
'   <a href="http://localhost/attorney/"><img src="http://localhost/attorney/wp-content/themes/attorney/images/headers/'.$img_rand[$img]['img'].'" width="'.$img_rand[$img]['wth'].'" height="'.$img_rand[$img]['hgt'].'" alt="'.$img_rand[$img]['alt'].'" /></a>

'
);
?>
But I would like it to use
PHP Code:
<?php
$img_rand 
= array(
   
=> array(
        
'img' => 'image5.jpg'// Add file name, type, even path if needed
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),                              
   
=> array(
        
'img' => 'image9.jpg',
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),
   
=> array(
        
'img' => 'image11.jpg',
        
'wth' => '751',        // Width if not a fixed variable
        
'hgt' => '109',        // Height if not a fixed variable
        
'alt' => 'ISC logo'  // Alt text... IF needed (consider this) 
),
);
?>
<?php
$img 
array_rand($img_rand);
echo(
'   <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/headers/'.$img_rand[$img]['img'].'" width="'.$img_rand[$img]['wth'].'" height="'.$img_rand[$img]['hgt'].'" alt="'.$img_rand[$img]['alt'].'" /></a>

'
);
?>
This doesn't work. Is there another way to write it so it works with WordPress?