I'm trying to add unique alt tags to my php code that reads images from a directory.
Is there a way to add alt tags without adding each image to a database with an "alt" column?
As long as you have some other way to determine what the alt tag's value should be, then sure. Without knowing what you really mean by "unique" alt tags, I can't really suggest anything off-hand (uniqid()? md5() hash of the file name? The current UNIX timestamp concatenated with the phase of the moon? )
PS: an empty string is a valid value for an alt tag, if you don't really have anything in mind for it and just want your HTML to be valid.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
The alt attribute is an attribute of the img tag and is meant to be an alternative for non-visual browsers when they come across images. This means, that the text is meant to be used when the image is not visible on the page. Instead, what is displayed is the alternative text.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)