Fixed issue with thumbnails

main
Thomas Ba. 4 years ago
parent 6a1b84a9c4
commit 9c7d740866

@ -20,14 +20,14 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
{{- if and $isimg (and (not $isthumb) (not $islarge)) }} {{- if and $isimg (and (not $isthumb) (not $islarge)) }}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension --> {{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
{{- $linkURL := print $baseURL ($.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 "(\\.)(gif|jpg|jpeg|tiff|png|bmp)$" ($thumbext | printf "%s.$2") }}<!-- 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 $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image --> {{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
{{- $large := .Name | replaceRE "(\\.)" ($largeext | printf "%s.") }}<!-- filename of thumbnail image --> {{- $large := .Name | replaceRE "(\\.)" ($largeext | printf "%s.") }}<!-- filename of thumbnail image -->
{{- $largeexists := where $files "Name" $large }}<!-- does a thumbnail image exist? --> {{- $largeexists := where $files "Name" $large }}<!-- does a thumbnail image exist? -->
{{- $largeURL := print $baseURL ($.Get "dir") "/" $large | absURL }}<!-- absolute URL to thumbnail image --> {{- $largeURL := print $baseURL ($.Get "dir") "/" $large | 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 }}');" >
<img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery --> <img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
</div> </div>

Loading…
Cancel
Save