I'm looking at customizing Gallery so that it better conforms with Web Accessibility Initiative Guidelines. The questions are:
- has anyone done any work on this, in version 1.x
- first issues are:
a) validation of HTML (or XHTML), there is no character encoding or doctype info imbedded in the Gallery pages I've tested, i.e. Gallery level. The validator refuses to proceed with validation under those conditions.
b) I can force the validator to parse the code by assuming a doctype and an encoding; I find there are missing ALT tags on all of the images.
c) I would like to remove the table formatting and replace it with CSS styled divs; this is a big, hairy job that I will hold off 'till last but any tips would be a help. Suggestions?
Could someone give me some hints about where to look for the code that generates these page features?
I understand that version 2.0 is more accessible. Is this code stable enough at this point to be put up on a web server and used in a quasi-production situation? As a lab for a series of accessibility redesign articles?
Thanks for any help. ...edN
Posts: 8
Here's my solution to the alt problem.
1. In classes/AlbumItem.php, add this function after the "var" lines:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> function getAltCaption() {
// function ADDED to add alt text to images
if ($this->caption) {
// only add the text before <br> in caption to alt tag
$myCaptionText = explode("<br>", $this->caption);
// remove double quotes from text
$myCaptionText[0] = eregi_replace(""", "'",$myCaptionText[0]);
if (strlen($myCaptionText[0]) > 200) {
$myCaptionText[0] = substr($myCaptionText[0], 0, 200);
// caption is too long, chop it
$myCaptionText[0] .= "...";
}
return " alt="" . $myCaptionText[0] .""";
}
else return "";
}
</TD></TR></TABLE><!-- BBCode End -->
2. In the same page, in the functions getThumbnailTag, getHighlightTag and getPhotoTag
ADD
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $attrs .= $this->getAltCaption(); </TD></TR></TABLE><!-- BBCode End -->
JUST BEFORE
the first "return" line of each function.
This should add the alt tag to all thumbnails using their caption.
Posts: 1301
Thanks, I'll give this a try!
Posts: 1301
Stupid question - but you've tested this and it works? I'm getting the following error message:
----------------------
Parse error: parse error in /gallery/classes/AlbumItem.php on line 50
Warning: Cannot send session cookie - headers already sent by (output started at /gallery/classes/AlbumItem.php:50) in /gallery/session.php on line 51
Warning: Cannot send session cache limiter - headers already sent (output started at /gallery/classes/AlbumItem.php:50) in /gallery/session.php on line 51
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition albumitem of the object you are trying to operate on was loaded _before_ the session was started in /gallery/classes/Album.php on line 718
----------------------
Do I need to add something to the classes/Album.php file as well?
Thanks!
Posts: 8
Yes, I have tested it out. And to the best of my knowledge I have posted all the changes that need to be done. Could you maybe send your AlbumItem.php to my email at
If I could sort out the problem, I would be glad.
Posts: 1
The problem appears to be with the triple quotes in both of the lines:
$myCaptionText[0] = eregi_replace(""", "'",$myCaptionText[0]);
and
return " alt="" . $myCaptionText[0] .""";
of the getAltCaption() function
I was able to fix the second line by simply replacing the double quote (") with a single quote. The new line should read:
return " alt='" . $myCaptionText[0] ."'";
As far as replacing the triple quote from the first line, I have no clue.
I've just commented it out and hoped (prayed?) that no one puts double quotes into the caption. There has to be a better way, but I'm stumped right now.
PLEASE, let me know if anyone figures this out.
Posts: 3474
Well... the problem then is that you can't use single quotes...
The best solution, I think, is to preprocess the caption and either strip all the double quotes, or replace them with single quotes.
As for the "triple" quotes, you need to escape the quote in the string with a backslash...