Jump to content

Image Alt Tags


jonesypeter

Recommended Posts

Hello,

 

I'm trying to add an alt tag to an image I am retrieving from a MySQL database but I am really struggling.  The image is displayed with:

 

echo "<td rowspan=3><img src=\"".$row['image_1']."\" > </td>";

 

 

What do I add include:

 

alt="some_text"

 

 

Many thanks

 

Peter Jones

 

 

 

Link to comment
Share on other sites

Since the image generation is dynamic, you have to have information about that image. Do you have the image's description in the database too? If not, you can just set the alt tag to be the filename of the image:

echo "<td rowspan=3><img alt=\"".$row['image_1']."\" src=\"".$row['image_1']."\" > </td>";
Link to comment
Share on other sites

Many thanks for the reply.  I have the field 'title' I can use.  So I have done:

 

echo "<td rowspan=3><img alt=\"".$row['title']."\" src=\"".$row['image_1']."\" > </td>";

 

 

The rendered HTML code comes through as:

 

<td rowspan=3><img alt="Firelord" src="/images/spectrum/loading/Firelord.gif" >

 

 

 

http://retro.getfreehosting.co.uk/retroseek.php?pid=1

 

The trouble is that the alt tag title is not appearing when I hover over the image

 

Thanks

 

Peter

Link to comment
Share on other sites

ALT is used to display text INSTEAD of the image if the user has images turned off, or they are using a non-graphical browser. Some browsers display the ALT value in a "tooltip" just because they want to. However, you can use the TITLE attribute, which (I believe) most browsers will display as a "tooltip" on hover.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.