Add Class To All Gallery Thumbnail Links

FooGallery Documentation

Add Class To All Gallery Thumbnail Links

In some scenarios you might want to add a specific class to all the anchor tags generated by FooGallery.

A practical example: some themes are hard coded to use certain lightboxes, so you might see 2 lightboxes shown when a gallery thumb is clicked (FooBox aswell as the lightbox packaged into the theme). The only way to turn off or disable the packaged lightbox is to add a class of “no-lightbox” onto the anchor tags.

You can do this by adding this code snippet to your functions.php file:

function foogallery_links_no_lightbox($attr, $args, $foogallery_attachment) {
    if ( ! isset( $attr[ 'class' ] ) ) {
        $attr[ 'class' ] = 'no-lightbox';
    } else {
        $attr[ 'class' ] .= ' no-lightbox';
    }
    return $attr;
}

add_filter( 'foogallery_attachment_html_link_attributes', 'foogallery_links_no_lightbox', 10, 3 );

Please note that this only works with the magnificPopup lightbox

FooConvert