Slimbox Plugin
[resolved] Fix to the regex bug breaking XHTML validation (1 post)

  1. ain
    Posted 4 years ago #

    The bug causes SlimBox to add rel attributes to all image tags that appear inside an anchor. By doing so it also breaks the standard/validation of the XHTML document by removing the trailing slash from the image and leaving it open.

    The problem: regex in the slimbox_create function is incorrect since it also returns a match for those anchors that don't link to the image file, but have an image wrapped in it, e.g.
    <a href="..html"><img ... /></a>

    The fix is to match the closure of the anchor:

    function slimbox_create($content){
    	return preg_replace('/<a(.*?)href=(.*?).(jpg|jpeg|png|gif|bmp|ico)"([.^>]*?)>/i', '<a$1href=$2.$3" rel="lightbox[roadtrip]" $4>', $content);


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Slimbox Plugin
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic