-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow dots in thumb path or filename #17
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,17 @@ | |
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ | ||
--> | ||
<!-- 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="{{ relURL "/css/hugo-easy-gallery.css" }}" />{{ end }} | ||
{{- $.Page.Scratch.Add "figurecount" 1 -}} | ||
<!-- use either src or link-thumb for thumbnail image --> | ||
{{- $filetype := index (findRE "[^.]+$" (.Get "link") ) 0 }} | ||
{{- $thumb := .Get "src" | default (printf "%s.%s" (replaceRE "\\.[^.]+$" (.Get "thumb") (.Get "link") ) $filetype ) | relURL }} | ||
<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"> | ||
<div class="img"{{ if .Parent }} style="background-image: url('{{ print .Site.BaseURL $thumb }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}> | ||
<div class="img"{{ if .Parent }} style="background-image: url('{{ print ($thumb | relURL) }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be simplified to |
||
<img itemprop="thumbnail" src="{{ $thumb }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery --> | ||
</div> | ||
{{ with .Get "link" | default (.Get "src") }}<a href="{{.}}" itemprop="contentUrl"></a>{{ end }} | ||
{{ with .Get "link" | default (.Get "src") }}<a href="{{. | relURL}}" itemprop="contentUrl"></a>{{ end }} | ||
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} | ||
<figcaption> | ||
{{- with .Get "title" }}<h4>{{.}}</h4>{{ end }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ | ||
--> | ||
<!-- 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="{{ relURL "/css/hugo-easy-gallery.css" }}" />{{ end }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment about leading slash |
||
{{- $.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"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
--> | ||
<!-- these files are loaded in the theme footer | ||
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> | ||
<script src="/js/load-photoswipe.js"></script> | ||
<script src="{{.Site.BaseURL}}/js/load-photoswipe.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to use {{ relURL "/js/load-photoswipe.js" }} to avoid a double slash in the output URL?, e.g. |
||
--> | ||
|
||
<!-- Photoswipe css/js libraries --> | ||
|
@@ -72,4 +72,4 @@ | |
</div> | ||
</div> | ||
</div> | ||
{{ end }} | ||
{{ end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
- If your template already loads jQuery in the footer, then you could load load-photoswipe.js from the footer instead | ||
--> | ||
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> | ||
<script src="/js/load-photoswipe.js"></script> | ||
<script src="{{.Site.BaseURL}}/js/load-photoswipe.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment about using |
||
|
||
<!-- Photoswipe css/js libraries --> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.css" integrity="sha256-sCl5PUOGMLfFYctzDW3MtRib0ctyUvI9Qsmq2wXOeBY=" crossorigin="anonymous" /> | ||
|
@@ -68,4 +68,4 @@ | |
</div> | ||
</div> | ||
</div> | ||
{{ end }} | ||
{{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using relURL do you need to remove the leading slash from the URL, e.g.
{{ relURL "css/hugo-easy-gallery.css" }}
or does it not matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slash doesn't matter. Hugo "does the right thing".