Changing the main images ALT text when the image changes.

Display several small images against a main product. Clicking these images swaps the main product image.
Post Reply
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Changing the main images ALT text when the image changes.

Post by norman »

You can use variables ExtraImage0 Alt Text ... ExtraImage6 Alt Text to display ALT text for the icons. If you'd like the main product image's ALT text to follow suit do the following:

Edit layout "Extra Image Table".

Look for the lines:

Code: Select all

echo "<img width=\"$iconwidth\" height=\"$iconheight\" src=\"$icontouse\"";
echo " alt=\"$alttext\"";
Replace them with:

Code: Select all

$alttext = htmlentities($alttext);
echo "<img width=\"$iconwidth\" height=\"$iconheight\" src=\"$icontouse\"";
echo " alt=\"$alttext\" title=\"$alttext\"";
Look for the line:

Code: Select all

$mouseovercode .= "document.getElementById('$productimageid').src='$extraimagetouse';";
Change this to be:

Code: Select all

$mouseovercode .= "var img=document.getElementById('$productimageid');img.src='$extraimagetouse';img.alt=this.alt;img.title=this.alt;";
Look for the line:

Code: Select all

echo " onclick=\"document.getElementById('$productimageid').src='$extraimagetouse'\"";
Change this to be:

Code: Select all

echo " onclick=\"var img=document.getElementById('$productimageid');img.src='$extraimagetouse';img.alt=this.alt;img.title=this.alt;\"";
Post Reply