简体   繁体   中英

Jekyll photo gallery without plugins

Is there a way to generate a Jekyll photo gallery which does not use plugins? I tried some, but it wasn't GitHub Pages friendly.

Now I'm using markdown, where I specify which pictures should be displayed, but I want to find some generic way to do this.

You can do something like this in your yml (in your .md file):

images:
  - image: /uploads/image5.jpg
  - image: /uploads/image6.jpg
  - image: /uploads/image7.jpg

And this in your layout file:

{% for item in page.images %}
<div class="lightbox" id="lightbox{{ forloop.index }}">
  <div class="table">
    <div class="table-cell">
      <img class="close" src="/img/close.svg" />
      <img class="next" src="/img/next.svg" />
      <img class="prev" src="/img/prev.svg" />
      <div class="item" style="background: url('{{ item.image }}') center center no-repeat; background-size: cover;">
      </div>
    </div>
  </div>
</div>
{% endfor %}

Together with some CSS and jQuery this can be your own custom lightbox. The jQuery should toggle the (next) lightbox. Something like this:

$('.next').click(function(){
  $(this).closest('.lightbox').hide().next().show();
});

UPDATE: I have created a simple lightbox for Jekyll that anyone can use without understanding javascript, HTML or CSS (or even Jekyll).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM