Support » Plugin: WP jQuery Lightbox » [Plugin: WP jQuery Lightbox] rel="lightbox" not working with do_shortcode function

  • Hi!

    I’ve been using this plugin in some projects and it’s amazing, thank you for your work!

    I have a little problem with a current project. Like always, when I use the plugin with the gallery shortocde like [gallery link="file"] it works fine inside the content.

    But now, I’ve found a problem using the gallery shortcode ousite the content. I’m running the gallery this way with the do_shortcode function: echo do_shortcode('[gallery link="file"]');

    Looking at the plugin code, I see that the filters which add the rel="lightbox" attribute are:

    add_filter('the_content', 'jqlb_autoexpand_rel_wlightbox', 99);
    add_filter('the_excerpt', 'jqlb_autoexpand_rel_wlightbox', 99);

    This filters are only running on the_content and the_excerpt, so I’m trying to add a filter to the do_shortcode function this way but it’s not working fine:
    add_filter('do_shortcode', 'jqlb_autoexpand_rel_wlightbox', 99);

    Do you know how can I make the do_shortcode function work?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ulfben


    Don’t know, but it’s a great question. I haven’t thought of the possibility of running filters manually like that.

    I’ll look into this for the next release.

    Plugin Author ulfben


    I’ve looked into this and the correct way to manually output a post gallery and apply lightbox to it is this;

    $gallery_output = do_shortcode('[gallery link="file" id="398"]');
    echo jqlb_autoexpand_rel_wlightbox($gallery_output);

    Notice post ID being set manually in the gallery shortcode.

    For the next release (out within an hour) I’ve added a convenience function – jqlb_apply_lightbox. Just feed it some content and a unique ID (number or string) for the set of pictures.

    $gallery_output = do_shortcode('[gallery link="file" id="398"]');
    		echo jqlb_apply_lightbox($gallery_output, "any ID");
    Plugin Author ulfben


    Perhaps the longest hour of my life. 🙂

    Version 1.3 is out, with a public method to run the Lightbox regexp on any string.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP jQuery Lightbox] rel="lightbox" not working with do_shortcode function’ is closed to new replies.