-
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?
Conversation
Thanks @it-gro, I'll review this asap. |
Same issue here. I just came here to report it. Edit: @it-gro's solution works great. Thanks. |
@it-gro and @HunterGraubard sorry that "asap" has turned into 12 months. Having a look now. |
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.
Hi @it-gro
Changes to fix the issue with dots in filename are all good. Thanks :-)
I have some queries about the use of relURL, probably all good, but please have a look.
And are there any other places where we should be using relURL instead of baseURL?
Regards
Li-Wen
{{- $.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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to {{ relURL $thumb }}
?
@@ -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 }} |
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".
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment about leading slash
@@ -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 comment
The 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. /path-to-my-site//js/load-photoswipe.js
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment about using relURL
Resolve liwenyip#17 Merge remote-tracking branch 'pr-it-gro/master' into production # Conflicts: # layouts/shortcodes/figure.html # layouts/shortcodes/gallery.html # layouts/shortcodes/load-photoswipe-theme.html # layouts/shortcodes/load-photoswipe.html
Thx for hugo-easy-gallery! Awesome!
I fixed an issue with the shortcodes (figure.html, gallery.html)
When a path or filename includes dot(s) a wrong thumb filename is assumed.
e.g.
{{< figure thumb="-thumb" link="/img/hugo.lorem.png" size="400x400" >}}
gives:
<img itemprop="thumbnail" src="/img/hugo-thumb.lorem-thumb.png"
instead of
<img itemprop="thumbnail" src="/img/hugo.lorem-thumb.png"
Test site is here:
https://github.com/it-gro/HugoTestingHegDotIssue
(using blank as theme)
I untabified gallery.html as well - but commited separately.
Thx again!