Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_image should generate alt attribute

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Roc
Smarty Rookie


Joined: 17 Apr 2003
Posts: 15

PostPosted: Mon Apr 21, 2003 11:22 pm    Post subject: html_image should generate alt attribute Reply with quote

As I understood the recent HTML recommendations from the W3 consortium, every <img> tag should always contain an "alt" attribute, even if it's empty. The W3 validator throws an error when the alt attribute is missing (HTML 4+ or XHTML).
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 04, 2003 3:06 am    Post subject: Reply with quote

Good idea.

For now, replace the line that starts with "return ..." at the end of the function.html_image.php file with:

Code:
$alt = (empty($params('alt'))) ? $params('file') : $params('alt');
return $prefix . '<img src="'.$file.'" alt="'.$alt.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;


This will have the alt text default to the filename if the optional alt parameter was not specified.
Back to top
View user's profile Send private message
Roc
Smarty Rookie


Joined: 17 Apr 2003
Posts: 15

PostPosted: Sun May 04, 2003 11:17 am    Post subject: Reply with quote

I think, an empty attribute (alt="") will be better as default. Try to browse a web site with lynx, and you'll see the reason: if the attribute is missing, lynx will display the filename instead, which make pages containing a lot of layout gifs quite unusable. I only want to specify alt in that cases, where it makes sense to have a text description for the image - either it contains a link or provides an information valuable to the user.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun May 04, 2003 11:39 am    Post subject: Reply with quote

fixed in cvs.

alt defaults to "" now and is always returned by html_image.
it's some days ago i did this. i didn't commit before, since i waited for an enlightenment on
http://phpinsider.com/smarty-forum/viewtopic.php?p=999

i wanted to update these two issues in one stroke. but since i don't have a 100% nice solution for topic 999, i committed the fix for the alt="" tag now.

have fun
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 04, 2003 12:03 pm    Post subject: Reply with quote

Quote:
I think, an empty attribute (alt="") will be better as default.


I agree if the link attribute is being used. Otherwise, it is pointless to include an alt="". The reason it is required is to allow accessability to users not loading images. If the link is there, there is no issue--but with no link, alt="" and no image loading--well, it provides nothing except for document validation. I could have probably chose something better than the filename--but SOMETHING should be put there!!

See: http://htmlhelp.com/feature/art3.htm
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun May 04, 2003 12:24 pm    Post subject: Reply with quote

i agree with you, boots, that something should be put there. but something reasonable can only be put there by the template-maker and not by {html_image}. so the default "" is okay to me.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 04, 2003 12:49 pm    Post subject: Reply with quote

Then isn't it better to not have a default of ""? The document not-validating is the last chance for the designer to catch the error. If the designer really doesn't want an alt, as in the case of a link, then perhaps they can expressily indicate an alt="".

Anyhow, I'm using my own library for this, so I won't complain Smile
Back to top
View user's profile Send private message
Roc
Smarty Rookie


Joined: 17 Apr 2003
Posts: 15

PostPosted: Sun May 04, 2003 4:15 pm    Post subject: Reply with quote

Using the file name as alt value doesn't make sense in many cases since the file name is often auto generated (e.g. MD5 hash), especially in typical situations when you need html_image like showing data from a database (e.g. product pictures in a shop). Then it's better to have nothing in the browser than "95950955kj54kr9840.jpg", I think.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP