-
-
Save ulfklose/1422e16e6f0216247b320851a8f2f65c to your computer and use it in GitHub Desktop.
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
<style> | |
div.gallery { | |
display: flex; | |
flex-wrap: wrap; | |
} | |
div.gallery a { | |
flex-grow: 1; | |
object-fit: cover; | |
margin: 2px; | |
display: flex; | |
} | |
div.gallery a img { | |
height: 200px; | |
object-fit: cover; | |
flex-grow: 1; | |
} | |
</style> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.0/jquery.fancybox.min.css" /> | |
<div class="gallery"> | |
{{ $base := .Get "src" }} | |
{{ $path := print "static/" (.Get "src") }} | |
{{ range (readDir $path) }} | |
{{- $thumbext := "-thumb" }} | |
{{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}<!-- is the current file a thumbnail image? --> | |
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? --> | |
{{- if and $isimg (not $isthumb) }} | |
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }} | |
<a data-fancybox="gallery" href="/{{ $base }}/{{ .Name }}"> | |
<img src="/{{ $base }}/{{ $thumb }}"> <br/> | |
</a> | |
{{- end }} | |
{{ end }} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment