Recent Topics

1 Oct 04, 2005 17:57    

This is a very simple hack. I wanted the "Description" field in File Upload form to be used as the title for the image in addition to the alt text. In admin/b2upload.php, I changed this line:

	$piece_of_code .= ' alt="'.$imgdesc.'" />';

To this:

	$piece_of_code .= ' alt="'.$imgdesc.'" title="'.$imgdesc.'" />';

Now the auto-generated code for the image includes both alt text and a title attribute. I suppose that some might want to have two seperate fields so they can make them different, but I'm satisfied with just using the same text for both.

To answer the obvious question of why bother defining both if they are the same: In Internet Explorer, when you mouse-over an image, it will display the alt text in a "tooltip". However, in Firefox, it displays the title text, not the alt text (which is probably the right thing to do). I recently switched my wife to using firefox, and she asked why the tooltips on her blog images quit working. I showed her how to add a title manually, but I figured it would be a simple hack to make it automatic.

2 Oct 04, 2005 18:22

In fact, it appears using title attribute only makes appearing the tooltips on both FF and IE. The alt attribute should be used as "alternative" display, when the image cannot be seen (because of impaired people or when the image loading failed). Anyway, adding both attributes makes everybody happy! :)

3 Oct 04, 2005 19:25

Yes, I guess I should have mentioned that IE will use the title if it's there, but uses the alt text if the title is not there. But, of course, the alt attribute is required by the XHTML DTD, so you must use it (and rightly so), even if you have a title.


Form is loading...