Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Nikita_Sp

    (@nikitasp)

    Seems the error is in jQuery selector, because it selects all links on the page.

    Thread Starter Nikita_Sp

    (@nikitasp)

    The problem is solved.

    In file wp-jquery-lightbox.php replace “rel” with “data-rel” on lines: 168, 169, 187:

    function jqlb_do_regexp($content, $id){
    	$id = esc_attr($id);
    	$pattern = "/(<a(?![^>]*?data-rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)(\?\S{0,}){0,1}['\"][^\>]*)>/i";
    	$replacement = '$1 data-rel="lightbox['.$id.']">';
    	return preg_replace($pattern, $replacement, $content);
    }
    
    function jqlb_filter_groups($html, $attr) {//runs on the post_gallery filter.
    	global $jqlb_group;
    	if(empty($attr['group'])){
    		$jqlb_group = -1;
    		remove_filter('wp_get_attachment_link','jqlb_lightbox_gallery_links',10,1);
    	}else{
    		$jqlb_group = $attr['group'];
    		add_filter('wp_get_attachment_link','jqlb_lightbox_gallery_links',10,1);
    	}
    	return '';
    }
    function jqlb_lightbox_gallery_links($html){ //honors our custom group-attribute of the gallery shortcode.
    	global $jqlb_group;
    	if(!isset($jqlb_group) || $jqlb_group == -1){return $html;}
        return str_replace('<a','<a data-rel="lightbox['.$jqlb_group.']"', $html);
    }

    In file jquery.lightbox.min.js replace:

    this.href&&this.rel==t.rel

    with

    this.href&&e(this).attr("data-rel")==e(t).attr("data-rel")

    OR IN FILE jquery.lightbox.js replace:

    if(!this.href || (this.rel != imageLink.rel)) {

    with

    if(!this.href || ($(this).attr("data-rel") != $(imageLink).attr("data-rel"))) {

    AND in both files replace

    jQuery('a[rel^="lightbox"]').lightbox({

    with

    jQuery('a[data-rel^="lightbox"]').lightbox({

    I hope it would help somebody)

    Thanks for the suggestions, and sharing your solution. I’ll take a look at it for the next update, but I’m not sure I’ll bother. I prefer plugin-, theme- and backwards compatibility over HTML5 validation.

    If I figure out a robust and simple way of supporting both, however, I’ll make it so.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replace attribute "rel" with "data-rel" to make HTML5 valid’ is closed to new replies.