• First off, I just want to say this is an awesome plugin!
    It’s one of the best I have found for galleries. It’s more attractive than many of the paid plugins with the same purpose that I have access to.

    I know this is asking for extra help, but I would really appreciate some insight into the issue I’m having.

    I would like to add a class to each image so I can use a lightbox that is built into the theme I’m using. (The lightbox requires that each image has the class in the anchor tag) It would be awesome if there was a shortcode for this function like there is a shortcode to put a class on the gallery container.

    Since there is not, I tried to do it myself with some Jquery, but after trying to implement a solution myself for a few hours… it has become clear that I’m not super talented with php and Jquery.

    I put the following in my functions.php

    <?php 
    
    function add_my_script() {
        wp_enqueue_script(
          'lightbox_bridge', get_stylesheet_directory_uri() . '/js/lightbox_bridge.js',
            array('jquery')
        );
    }
    add_action( 'wp_enqueue_scripts', 'add_my_script' );

    And added the following Jquery file (lightbox_bridge.js)

    jQuery(document).ready(function(){
      jQuery('div.gallery').each(function(i) {
    	jQuery('.bbg-img').parents('a').addClass('et_pb_lightbox_image');
      });
    });

    I haven’t had any luck so far… I’m hoping you can offer a more elegant solution. I would really appreciate it… Any suggestions you have would be greatly appreciated! Thanks in advance!

    https://ww.wp.xz.cn/plugins/responsive-gallery-grid/

Viewing 1 replies (of 1 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    No need,

    there is a shortcode parameter called class for this.

    Cheers
    Jules

    EDIT: woops sorry, that will not work. it will only add a class to the container. I’ll add an item-class parameter to the next update.

Viewing 1 replies (of 1 total)

The topic ‘Adding a class to each anchor tag’ is closed to new replies.