Lightbox 2 and XHTML 1.1 validation

14 Apr

I recently started using the Lightbox 2 WordPress plugin on my Marbella news site to automatically add the zooming overlay effect to certain images. It is really plug & play and works out of the box.

I did encounter however that my pages stopped validating as XHTML 1.1 which is the standard doctype on all sites I develop.

The error in question is due to the square brackets (“[” and “]”) being used to link individual images in one single post together as a gallery under the “rel” attribute. The square brackets are not permitted characters and therefore the W3 Validator spits out the following error message:

character "[" is not allowed in the value of attribute "rel"
It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit.

To avoid this XHTML 1.1 validation problem simply edit the following line in the Lightbox 2 plugin file named lightbox2.php under the “autoexpand_rel_wlightbox” function:


$replacement    = '$1 rel="lightbox['.$post->ID.']">';


$replacement    = '$1 rel="lightbox_'.$post->ID.'">';

You should now be able to validate that plugin’s output as XHTML 1.1 with no issues.

Comment Form