Photoswipe plugin (a Lightbox like gallery)

Here’s my another plugin if you need a nice vanilla JS Lightbox like gallery

Live demo (extended a bit)
Also note- photo grid is not a part of the plugin :slight_smile:

4 Likes

Thank you, very nice :+1: regards.

1 Like

Great plugin, this way I can build a website without jQuery and still have a nice gallery.
I have one issue though, if I enable caching in system config, it loads photoswipe assets only on the first page load, all the others both js and css assets are gone. Have you experienced anything like this? How could I solve it?

Strange. I have caching enabled always and assets are always loaded :thinking:
Would have to look into it if I can reproduce

Yes, very strange behavior. I didn’t realize at first because I had cache disabled during development and only realized after I had included the gallery into my templates. So I reverted everything exactly like your documentation on github but the problem persists.

I’ll try to give you more info on my setup:

I’m on the latest stable Grav version with admin and other plugins.
I’m including css and js from the base theme like this:

{% block stylesheets %}
    {% do assets.addCss('theme://dist/css/main.min.css?v=1.0.1', 102) %}
    {% do assets.addCss('theme://dist/css/main.css.min.map?v=1.0.1', 101) %}
{% endblock %}

{% block javascripts %}
    {# {% do assets.addJs('jquery', 103) %} #}
    {% do assets.addJs('bootstrap', 102) %}
{% endblock %}

{% block assets deferred %}
    {{ assets.css()|raw }}
    {{ assets.js()|raw }}
{% endblock %}

It works perfectly with cache disables or with “never cache twig” enabled on the gallery modular page, which is what I’m doing right now.
Otherwise at the second refresh photoswipe css and js are not loaded anymore.

I tried on a different Grav install (v1.7.10) as well and it’s doing the same.

Could you please create a new issue with all the info you provided here? Just so that I would not forget it. Thanks

1 Like