~xdavidwu/xdavidwu.link

ref: b721023f72acc0f8db9bd2c74d7a2e0fb7fb0d1e xdavidwu.link/_includes/gallery -rw-r--r-- 1.4 KiB
b721023f — Michael Rose Fix typo and update link to beta release post 8 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{% include base_path %}

{% if include.id %}
  {% assign gallery = page.[include.id] %}
{% else %}
  {% assign gallery = page.gallery %}
{% endif %}

{% if gallery.size == 2 %}
  {% assign gallery_layout = 'half' %}
{% elsif gallery.size >= 3 %}
  {% assign gallery_layout = 'third' %}
{% else %}
  {% assign gallery_layout = '' %}
{% endif %}

<figure class="{{ gallery_layout }} {{ include.class }}">
  {% for img in gallery %}
    {% if img.url %}
      <a href=
        {% if img.url contains "://" %}
          "{{ img.url }}"
        {% else %}
          "{{ img.url | prepend: "/images/" | prepend: base_path }}"
        {% endif %}
        {% if img.title %}title="{{ img.title }}"{% endif %}
      >
        <img src=
          {% if img.image_path contains "://" %}
            "{{ img.image_path }}"
          {% else %}
            "{{ img.image_path | prepend: "/images/" | prepend: base_path }}"
          {% endif %}
          alt="{% if img.alt %}{{ img.alt }}{% endif %}">
      </a>
    {% else %}
      <img src=
        {% if img.image_path contains "://" %}
          "{{ img.image_path }}"
        {% else %}
          "{{ img.image_path | prepend: "/images/" | prepend: base_path }}"
        {% endif %}
        alt="{% if img.alt %}{{ img.alt }}{% endif %}">
    {% endif %}
  {% endfor %}
  {% if include.caption %}
    <figcaption>{{ include.caption | markdownify | remove: "<p>" | remove: "</p>" }}</figcaption>
  {% endif %}
</figure>