Skip to content

Commit

Permalink
Update to latest version of hugo-easy-gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Romero committed Sep 18, 2018
1 parent 7de7846 commit b0cf886
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions layouts/shortcodes/figure.html
Expand Up @@ -10,9 +10,10 @@
{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} {{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }}
<div class="box{{ with .Get "caption-position" }} fancy-figure caption-position-{{.}}{{end}}{{ with .Get "caption-effect" }} caption-effect-{{.}}{{end}}" {{ with .Get "width" }}style="max-width:{{.}}"{{end}}> <div class="box{{ with .Get "caption-position" }} fancy-figure caption-position-{{.}}{{end}}{{ with .Get "caption-effect" }} caption-effect-{{.}}{{end}}" {{ with .Get "width" }}style="max-width:{{.}}"{{end}}>
<figure {{ with .Get "class" }}class="{{.}}"{{ end }} itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <figure {{ with .Get "class" }}class="{{.}}"{{ end }} itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumb }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}> <div class="img"{{ if .Parent }} style="background-image: url('{{ print .Site.BaseURL $thumb }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
<img itemprop="thumbnail" src="{{ $thumb }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery --> <img itemprop="thumbnail" src="{{ $thumb }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
</div> </div>
{{ with .Get "link" | default (.Get "src") }}<a href="{{.}}" itemprop="contentUrl"></a>{{ end }}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption> <figcaption>
{{- with .Get "title" }}<h4>{{.}}</h4>{{ end }} {{- with .Get "title" }}<h4>{{.}}</h4>{{ end }}
Expand All @@ -24,6 +25,5 @@
{{- end }} {{- end }}
</figcaption> </figcaption>
{{- end }} {{- end }}
{{ with .Get "link" | default (.Get "src") }}<a href="{{.}}" itemprop="contentUrl"></a>{{ end }}<!-- put <a> last so it is stacked on top -->
</figure> </figure>
</div> </div>
7 changes: 4 additions & 3 deletions layouts/shortcodes/gallery.html
Expand Up @@ -5,6 +5,7 @@
<!-- count how many times we've called this shortcode; load the css if it's the first time --> <!-- count how many times we've called this shortcode; load the css if it's the first time -->
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="/css/hugo-easy-gallery.css" />{{ end }} {{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="/css/hugo-easy-gallery.css" />{{ end }}
{{- $.Page.Scratch.Add "figurecount" 1 }} {{- $.Page.Scratch.Add "figurecount" 1 }}
{{ $baseURL := .Site.BaseURL }}
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery"> <div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
{{- with (.Get "dir") -}} {{- with (.Get "dir") -}}
<!-- If a directory was specified, generate figures for all of the images in the directory --> <!-- If a directory was specified, generate figures for all of the images in the directory -->
Expand All @@ -16,10 +17,10 @@
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? --> {{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
{{- if and $isimg (not $isthumb) }} {{- if and $isimg (not $isthumb) }}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension --> {{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
{{- $linkURL := print ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image --> {{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image --> {{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
{{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? --> {{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
{{- $thumbURL := print ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image --> {{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
<div class="box"> <div class="box">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" > <div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" >
Expand All @@ -37,4 +38,4 @@
<!-- If no directory was specified, include any figure shortcodes called within the gallery --> <!-- If no directory was specified, include any figure shortcodes called within the gallery -->
{{ .Inner }} {{ .Inner }}
{{- end }} {{- end }}
</div> </div>
2 changes: 2 additions & 0 deletions static/css/hugo-easy-gallery.css
Expand Up @@ -123,6 +123,7 @@ figcaption styles
font-size: 75%; /* change this if you want bigger text */ font-size: 75%; /* change this if you want bigger text */
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
opacity: 1; opacity: 1;
cursor: pointer;
} }
.gallery.caption-position-none figcaption, .gallery.caption-position-none figcaption,
.fancy-figure.caption-position-none figcaption { .fancy-figure.caption-position-none figcaption {
Expand Down Expand Up @@ -155,3 +156,4 @@ figcaption styles
figcaption p { figcaption p {
margin: auto; /* override style in theme */ margin: auto; /* override style in theme */
} }

0 comments on commit b0cf886

Please sign in to comment.