Created
February 10, 2019 02:44
-
-
Save marksteele/38aa7ce30608da6c5182527105e79b0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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