Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: include a gallery on a page using Liquid Includes #33

Open
nathanbirrell opened this issue Jan 18, 2017 · 1 comment
Open

Feature: include a gallery on a page using Liquid Includes #33

nathanbirrell opened this issue Jan 18, 2017 · 1 comment

Comments

@nathanbirrell
Copy link

See my fork of this repo for a working example of this: https://github.com/nathanbirrell/jekyll-gallery-generator

Essentially it enables you to include a specific gallery on any page using a tag, for example: {% gallery my-gallery %}.

(My repo also includes a few other bits of refactoring that can be used or ignored.)

@gertoe
Copy link
Contributor

gertoe commented Mar 3, 2020

See my fork of this repo for a working example of this: https://github.com/nathanbirrell/jekyll-gallery-generator

Essentially it enables you to include a specific gallery on any page using a tag, for example: {% gallery my-gallery %}.

(My repo also includes a few other bits of refactoring that can be used or ignored.)

This feature is quite useful but is, currently, hard to merge and changes the gallery generator behaviour too much, I suppose. Furthermore, I have unsuccessfully been trying to make your changes work with recent gallery-generator releases since last year.

However, it is already possible to include a specific gallery using a kind-of hacky workaround for which I would like to propose a drop of the auto-capitalisation of the gallery names. The latter makes it harder to determine the correct gallery name.

My workaround is based on the answer originally posted by @sanyen in issue #41 (comment). The requested gallery (test album in the example below) is determined from the galleries found on all (gallery) pages jekyll may build. This solution is not the most performant one due to the determination procedure, but it works sufficiently well, at least for my purposes; we are not building the next global multimedia platform with the the help of Jekyll, aren't we?

Notwithstanding this, hidden galleries cannot be found/included this way!

A better approach might still be to store the galleries in a dictionary or something similar which can be accessed by the liquid includes directly.

To handle special characters (as well as whitespaces if not replaced by the gallery generator), the url_encode.rb plugin may be used.

Maybe, it is possible to create a wrapper for the snippet to include a gallery using a single Liquid macro only.

{% for p in site.pages %}
  {% for gallery in p.galleries %}
  <div class="gallery">
    {% if gallery['gallery'] == "test album" %}
      {% for image in gallery.images %}
      <div class="gallery-image-wrapper">
        <a name="{{ image.name }}"></a>

        <!-- link correct gallery folder/image:
          site.gallery.dir   -> dir of galleries
          gallery['gallery'] -> directory of gallery requested (see above), "gallery name"
          Do so for the thumbnail, respectively...
        -->
        <a href="{{ site.gallery.dir }}/{{ gallery['gallery'] }}/{{ image.src }}">
          <img class="gallery-image" src="{{ site.gallery.dir }}/{{ gallery['gallery'] }}/thumbs/{{ image.src }}" />
        </a>
      </div>
      {% endfor %}
    {% endif %}
  </div>
  {% endfor %}
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants