WordPress.org

Ready to get started?Download WordPress

Forums

WP jQuery Lightbox
[resolved] No auto-lightboxing for gallery link in template (5 posts)

  1. owenwalz
    Member
    Posted 2 years ago #

    Hi,

    I'm having trouble getting auto-lightboxing on this line of code in my template:

    <?php echo do_shortcode('[gallery columns="4" link="file"]'); ?>

    It just links to the file with no lightbox. If I click on the image in its attachment page it WILL lightbox, so something is working (just not this gallery).

    Any ideas? Thanks,

    http://wordpress.org/extend/plugins/wp-jquery-lightbox/

  2. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    Link to the template page please.

  3. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    You could try:

    jqlb_apply_lightbox(do_shortcode('[gallery columns="4" link="file"]'), "any ID");

  4. thelamingtontree
    Member
    Posted 2 years ago #

    Sorry to revive a really old thread, but I am having the same problem. That last code you posted work. However instead of taking the post ID as a rel (rel="lightbox[86]") it prints out some large integer (rel="lightbox[134181907414754]").

    I'll have a look some more for a solution but if you know what's up with that really large number and already have a solution, let me know :)

    EDIT:

    I should've really tried this fix before posting above, but the fix is to change some lines in wp-jquery-lightbox/wp-jquery-lightbox.php (Installed plugins -> jQuery Lightbox -> Edit -> first file on the list)

    1. Search for function jqlb_do_regexp($content, $id)
    2. Add global $post after the first curly bracket (before $id = blah)
    3. Change $replacement = '$1 rel="lightbox['.$id.']">'; to $replacement = '$1 rel="lightbox['.$post->ID.']">';

    Note that the above fix is not endorsed by the creator (yet) and usage testing is extremely limited to my case.

  5. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    All the lightboxing functions expects two parameters - the content (HTML markup) to box, and an ID for the set. The ID can be anything - jqlb_autoexpand_rel_wlightbox (= the automatic shortcode handler) uses the post ID whereas the jqlb_apply_lightbox (= the public method you're using) falls back to a random number.

    Ergo: when you're calling the functions yourself, you're supposed to provide an ID for your sets. If you want it to use the post ID, give it the post id. There's no need to alter the plugin source.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic