I have been using a code to call up specific images depending on the page that is being visited. However, when the images are displayed the alt information is missing from the image details/properties. The site has to have the alt information added to all images for accessibility, and I'm not sure where I can add the alt attribute in the code in order for the information to show up. I would also like the alt info to be relevant to the image, so it will need to change with each image. Any ideas anyone???
The code that switches the image depending on the page:
<?php
function sectImage($sect='home')
{
switch($sect)
{
case 'home':
$img = 'images/mainpage.jpg';
break;
case 'news':
$img = 'images/newspage.jpg';
break;
case 'biog':
$img = 'images/imgpage.jpg';
break;
case 'career1':
$img = 'images/carpage.jpg';
break;
case 'career2':
$img = 'images/carpage.jpg';
break;
case 'gallery':
$img = 'images/galpage.jpg';
break;
case 'media':
$img = 'images/medpage.jpg';
break;
case 'contact':
$img = 'images/contpage.jpg';
break;
default:
$img = 'images/error.gif';
break;
}
return $img;
}
?>
The code calling the images on the page:
<img src="<?php echo sectImage($_GET['page']); ?>" class="padded">
Obviously I can add the alt tag directly to the code above, but that will mean every image will be the same, and I don't want that. However, if that is not possible, I guess I will have to go for the generic alt.