Created
March 13, 2018 11:35
-
-
Save letrastudio/4e678722e0b7400655ecd15fa33d6e0d to your computer and use it in GitHub Desktop.
Loop though media files in a Jekyll collection and display them in a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- | |
<ul> | |
{% assign collection = site.collections | where: 'label', 'uploads' | first %} | |
{% for file in collection.files %} | |
{% assign extension = file.extname | downcase %} | |
{% case extension %} | |
{% when ".jpg" or ".jpeg" or ".png" or ".gif" or ".svg" %} | |
<li><img src="/uploads/{{ file.name }}"></li> | |
{% when ".mp4" %} | |
<li><video controls src="/uploads/{{ file.name }}"></video></li> | |
{% else %} | |
<li><a href="/uploads/{{ file.name }}">{{ file.name }}</a></li> | |
{% endcase %} | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment