Description:
I upgraded to Joomla 1.0.9 stable version, later I opened the W3C HTML Validator, and it found an enormous amount of errors, all were caused by missing attribute alt in img tags. All of these img-s were using my template's images.
Reported on:
Joomla 1.0.9 stable
Classification:
Low
Affected functions:
Related files:
Steps to replicate:
Analysis:
Proposed fix(es):
In includes/joomla.php the line 4942 looked like that:
$image = '';
After an alteration to this:
$image = '';
in worked perfectly.
Topic / Artifact ID:
Enter the crosss reference for topic or artifact id/url when submitted
System info:
Enter your system info
[FIXED] No alt tag with non default images 1.0.9 W3C incompatibility
- stampie
- Joomla! Apprentice
- Posts: 44
- Joined: Mon May 29, 2006 12:38 pm
- Location: Hungary
- Contact:
[FIXED] No alt tag with non default images 1.0.9 W3C incompatibility
Last edited by stingrey on Fri Jun 16, 2006 3:22 pm, edited 1 time in total.
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
Re: Version 1.0.9 W3C incompatibility
Looking at the function ImageCheck, it does appear that the change in code from 1.0.8 to 1.0.9 means that if the function is not passed a value for alt, then it will not print the usual empty alt=""
here is the function in 1.0.9
Although the fix mentioned by stampie, I think will only work in situations where no alt is passed. If a value for alt is passed to the function, I guess it would produce: alt="alt="something""
I am not actually sure which situations call this function so I cannot test my theory but I would guess that the line
which only outputs an alt tag if a value is passed
could be replaced with
which will always output an alt tag
stampie, can you give details of which situation this occurs in so that it can be tested. I thought at first it may be menu icons or indent images, but they seem to get an alt tag ok.
where in the joomla frontend output are the images?
can you give a link?
here is the function in 1.0.9
Code: Select all
<?php
function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='middle', $title=NULL ) {
global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe;
$cur_template = $mainframe->getTemplate();
$name = ( $name ? 'name="'. $name .'"' : '' );
$title = ( $title ? 'title="'. $title .'"' : '' );
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
if ( $param ) {
$image = $mosConfig_live_site. $param_directory . $param;
if ( $type ) {
$image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" '. $name .' border="0" />';
}
} else if ( $param == -1 ) {
$image = '';
} else {
if ( file_exists( $mosConfig_absolute_path .'/templates/'. $cur_template .'/images/'. $file ) ) {
$image = $mosConfig_live_site .'/templates/'. $cur_template .'/images/'. $file;
} else {
// outputs only path to image
$image = $mosConfig_live_site. $directory . $file;
}
// outputs actual html <img> tag
if ( $type ) {
$image = '<img src="'. $image .'" align="'. $align .'" '. $alt .' '. $name .' '. $title .' border="0" />';
}
}
return $image;
}
?>
I am not actually sure which situations call this function so I cannot test my theory but I would guess that the line
Code: Select all
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
could be replaced with
Code: Select all
$alt = 'alt="'. $alt .'"';
stampie, can you give details of which situation this occurs in so that it can be tested. I thought at first it may be menu icons or indent images, but they seem to get an alt tag ok.
where in the joomla frontend output are the images?
can you give a link?
Do you want the answer to be as vague as your question?
- stampie
- Joomla! Apprentice
- Posts: 44
- Joined: Mon May 29, 2006 12:38 pm
- Location: Hungary
- Contact:
Re: Version 1.0.9 W3C incompatibility
I looked at the same code when was looking for the error. The problem with your solution is, that the line is before the if statement, and in the first part an other line exist: . Your solution would produce alt="alt="... result, which would break the page. My solution wrote in the first comment looks like it's working in every situation.
Code: Select all
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
Code: Select all
$image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" '. $name .' border="0" />';
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
Re: Version 1.0.9 W3C incompatibility
I had not noticed that there were two lines with two different methods I had just looked at the line you showed where you replaced
$alt
with
alt="'. $alt .'"
which would also produce alt="alt="something"" when a value was passed for the alt tag
I seems that it should only be one way or the other.
either this
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
should be made to always give
$alt = 'alt="'. $alt .'"';
and lower down always echo'ed as
$alt
or this line
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
removed altogether and lower down both use
alt="'. $alt .'"
I guess we can leave it to the devs to decide which way to fix it
Can you let me know which kind of output is displaying these missing tags.
$alt
with
alt="'. $alt .'"
which would also produce alt="alt="something"" when a value was passed for the alt tag
I seems that it should only be one way or the other.
either this
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
should be made to always give
$alt = 'alt="'. $alt .'"';
and lower down always echo'ed as
$alt
or this line
$alt = ( $alt ? 'alt="'. $alt .'"' : '' );
removed altogether and lower down both use
alt="'. $alt .'"
I guess we can leave it to the devs to decide which way to fix it
Can you let me know which kind of output is displaying these missing tags.
Do you want the answer to be as vague as your question?
- stampie
- Joomla! Apprentice
- Posts: 44
- Joined: Mon May 29, 2006 12:38 pm
- Location: Hungary
- Contact:
Re: Version 1.0.9 W3C incompatibility
Right now I noticed, that even my solution is wrong for the same reason - it works wrong, when an alt tag _is_ given as a parameter, because then it shows alt="alt="... result, which is wrong.
These images are used to show e.g. the category icons, rating icons etc. in many built-in components and modules. Ratings doesn't give an alt tag, meanwhile the printbutton gives alt="Nyomtatás" (Nyomtatás from the language file).
I suggest another solution: don't give the default value as NULL but as 'alt=""'. And the original code in line 4942 has to be written back.
I haven't tried it yet, but I will do it.
These images are used to show e.g. the category icons, rating icons etc. in many built-in components and modules. Ratings doesn't give an alt tag, meanwhile the printbutton gives alt="Nyomtatás" (Nyomtatás from the language file).
I suggest another solution: don't give the default value as NULL but as 'alt=""'. And the original code in line 4942 has to be written back.
I haven't tried it yet, but I will do it.
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
[SUBMITTED TO TRACKER] Re: Version 1.0.9 W3C incompatibility
Do you want the answer to be as vague as your question?
- stingrey
- Joomla! Hero
- Posts: 2756
- Joined: Mon Aug 15, 2005 4:36 pm
- Location: Marikina, Metro Manila, Philippines
- Contact:
Re: [FIXED] No alt tag with non default images 1.0.9 W3C incompatibility
Fixed in SVN
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me
Partner, Business Development & Project Manager, Event Manager, Sports Coach
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me
Partner, Business Development & Project Manager, Event Manager, Sports Coach