• zr668

    (@zr668)


    I can’t get gallery groups to work. My page contains 3 galleries, each with its own group name.
    [gallery link="file" ids="848,845" group="lam"]
    [gallery link="file" ids="870,869,868" group="2" ]
    [gallery link="file" ids="856,857,854,855" group="c"]

    The above will display a gallery of 9 images, regardless of which image you click. It always starts on the image you click, but cycles through all images in all galleries on that page.

    I’ve confirmed that wp_header() and wp_footer() are in the right place. No javascript optimizers are used. I’ve tested all plugins and confirmed that the gallery groups work fine with all except Jetpack.

    Specifically, it’s the Tiled Galleries component that’s the problem. If I disable that, groups work again.

    I’ve tried toggling a variety of settings in Jetpack and jQuery lightbox, but can’t get the combination of lightbox and tiled/mosaic gallery to work.

    WP 4.2.1
    jQuery lightbox 1.4.6
    Jetpack 3.5

    Same behaviour in Chrome 42.0.x, Opera 28.0.x & IE 11.0.x

    Any thoughts on what I can try next?

    https://wordpress.org/plugins/wp-jquery-lightbox/

Viewing 6 replies - 1 through 6 (of 6 total)
  • ulfben

    (@ulfben)

    It sounds like Tiled Galleries filters the shortcode and removes any flags it doesn’t recognize. You could try playing with the filter priorities in these plugins, see if you can get wp-jquery-lightbox’s filter to run before Jetpack’s.

    Thread Starter zr668

    (@zr668)

    Hi Ulf, thanks for the quick reply.

    Jetpack 3.5.2 was released overnight. I’ve updated, but no change in behaviour. 🙁

    As suggested, I’ve played with filter priority, focusing on the tiled gallery component. In plugins/jetpack/modules/tiled-gallery.php, line 149, I find this:
    add_filter( 'post_gallery', array( $gallery, 'gallery_shortcode' ), 1001, 2 );

    Lowering the priority to 9 or less changes the behaviour (jqlb is set to 10). Lightbox grouped galleries work again, but the static tiled/mosaic gallery is now broken (just as if I disabled it in Jetpack settings).

    So now I’m into the proverbial rabbit hole and getting deeper! Please note, I’m ok with PHP, but have zero experience in WP development.

    In the HTML for the broken page/gallery, I can see that all the <a> links to gallery images have been written with a “rel=lightbox[843]” parameter, presumably by the jetpack plugin, since it is in a <div>-based mosaic layout. The jqlb group name isn’t being passed into the address link, jetpack is just using my post’s ID throughout. Manually altering the rel parameter to the right group name and saving as static HTML restores correct behaviour.

    I would have thought that the priority of 10 for jqlb gave it the opportunity to set that parameter before passing over to the jetpack plugin (set at 1001). As mentioned above, I’m not familiar with WP to this level of detail, so I’m not sure where to look next (short of abandoning one or other of these plugins). I’m more than happy to change a some PHP or alter parameters, but it’s a very steep learning curve from where I am right now!

    I just don’t know where to begin untangling the interations between the WP engine and the layers of plugins…

    Any further thoughts or tips?

    Again, thanks!
    zr668

    ulfben

    (@ulfben)

    Thanks for the follow up.

    I’d need to install Jetpack to see if there’s any way to make these two play nice with each other. That won’t happen anytime soon though – it’s end of semester times right now, so I’m fcked for time.

    You could try asking the tiled gallery people if they have any idea for a fix?

    Thread Starter zr668

    (@zr668)

    No worries Ulf, thanks.

    I’ve logged this through jetpack support — will update you if I get a response, but there’s been nothing as yet.

    Best of luck with the studies!

    Thread Starter zr668

    (@zr668)

    Update:
    I’ve had a little to and fro with Jetpack support, and they’ve logged this as a feature request for a future release — https://github.com/Automattic/jetpack/issues/2134

    The request specifically notes this might be resolved by adding a filter on L4 of modules/tiled-gallery/tiled-gallery/templates/partials/item.php

    I dug a little deeper after they pointed me to the file above, and eventually came up with the hack below. It really is a hack, since I’ve only learned the minimum required about WordPress to get my result…

    In the file /plugins/jetpack/modules/tiled-gallery/tiled-gallery.php, after line 120, I added the following:

    if (isset($atts['group'])) {
    			$jqlbgrp = $atts['group'];
    			$gallery_html = preg_replace("/<a href=(\".*?)>/i","<a href=$1 rel=lightbox[$jqlbgrp]>",$gallery_html);
    			_log(get_defined_vars());
    			}

    … effectively moving the link expansion defined in jqlb_autoexpand_rel_wlightbox() into the JP tiled gallery module. This is the only place I was able to find $atts['group'] still defined while the <a> link was being constructed, so I shoehorned it in.

    Not very pretty, I know, but the functionality I’m after is there now.

    Thanks again for your help and for the plugin!

    ulfben

    (@ulfben)

    Thank you very much for following up on this. I’ll make sure I take a look at their issue tracker before releasing the next update, to see if there’s anything I can do on my end too.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Can't get grouping to work when Jetpack Tiled Galleries is active’ is closed to new replies.