hacks-guide-minimal-mistake.../_includes/gallery

51 lines
1.5 KiB
Text
Raw Normal View History

{% include base_path %}
{% if include.id %}
{% assign gallery = page.[include.id] %}
{% else %}
{% assign gallery = page.gallery %}
{% endif %}
{% capture gallery_size %}{{ gallery | size }}{% endcapture %}
{% 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 %}
2016-03-06 03:29:08 +01:00
{% if img.url %}
<a href=
2016-03-06 03:29:08 +01:00
{% if img.url contains "http" %}
"{{ img.url }}"
{% else %}
"{{ img.url | prepend: "/images/" | prepend: base_path }}"
{% endif %}
{% if img.title %}title="{{ img.title }}"{% endif %}
>
<img src=
2016-03-06 03:29:08 +01:00
{% if img.image_path contains "http" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | prepend: "/images/" | prepend: base_path }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
</a>
{% else %}
<img src=
2016-03-06 03:29:08 +01:00
{% if img.image_path contains "http" %}
"{{ 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>