Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jpescador/hugo-future-imperfect.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Pescador <jpescador@users.noreply.github.com>2016-02-27 02:47:41 +0300
committerJulio Pescador <jpescador@users.noreply.github.com>2016-02-27 02:47:41 +0300
commit9adee7c9aeaf746246acbfa0efe5497c5563612f (patch)
tree31d74ef58266bd7e4d61fb350e860afea9242a27
parent87003c657ab06248592fe6dfb0a50e962a723d59 (diff)
Can now add alt text to an imagev0.16
The alt text value can be provided in the intro pic by setting the site param: [params.intro.pic] alt = "set text" The shortcodes img-fit and img-post can now set the alt text value. The parameter for img-post is the last position or the named parameter alt. Here is an example for both: {{< img-post "date" "file.jpg" "left" "alt text" >}} {{< img-post path="date" file="file.jpg" type="left" alt="text" >}} img-fit has changed slightly. The first parameter will not be the path. Instead, that will always be the last parameter. You still have the ability to place as many images as needed in this shortcode call. postion: 0: width of column 1-12 in u or u$ 1: filename including extension 2: alt text 3: same as pos 0 4: same as pos 1 5: same as pos 2 ... n-3 n-2 n-1 n: name of the path
-rw-r--r--layouts/partials/sidebar.html6
-rw-r--r--layouts/shortcodes/img-fit.html44
-rw-r--r--layouts/shortcodes/img-post.html46
3 files changed, 58 insertions, 38 deletions
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 53390fa..e8fbf9e 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -6,9 +6,11 @@
{{ $pic := .Site.Params.intro.pic }}
{{ with $pic.src }}
{{ if $pic.circle }}
- <img src="{{ . }}" class="intro-circle" width="{{ $pic.width }}" alt="" />
+ <img src="{{ . }}" class="intro-circle" width="{{ $pic.width }}" alt="{{ $pic.alt }}" />
+ {{ else if $pic.imperfect }}
+ <a href="/" class="logo"><img src="{{ . }}" alt="{{ $pic.alt }}" /></a>
{{ else }}
- <img src="{{ . }}" width="{{ $pic.width }}" alt="" />
+ <img src="{{ . }}" width="{{ $pic.width }}" alt="{{ $pic.alt }}" />
{{ end }}
{{ end }}
<header>
diff --git a/layouts/shortcodes/img-fit.html b/layouts/shortcodes/img-fit.html
index 1b34ef6..70b4a69 100644
--- a/layouts/shortcodes/img-fit.html
+++ b/layouts/shortcodes/img-fit.html
@@ -1,37 +1,45 @@
-<!-- params 3-n(odd value)
+<!-- params 4-n(3rd odd value + 1)
Strictly positional
Can create a gallery of multiple rows
with multiple images using this shortcode
position 0
- Can pass in the following values:
- title: will use /img/LinkTitle as the path
- date: will use /img/year/month as the path
- /path/to/img: can pass in the explicit path to the image
-
- position 1
Pass in the width of the column in the row, e.g 6u
- The width has a max size of 12
- Set the value by also adding the letter u at the end like so: 4u
- Can also end the row and start a new one
by adding the character $ like so: 8u$
- position 2
+ position 1
Pass in the name of the file including the extension of the file type
+ position 2
+ Alt name for image, can be left as an empty string "" if no text is desired
+
position 3
same as position 1
position 4
same as position 2
+
+ position 5
+ same as position 3
...
+ position n-3
+
+ position n-2
+
position n-1
position n
+ Can pass in the following values:
+ title: will use /img/LinkTitle as the path
+ date: will use /img/year/month as the path
+ /path/to/img: can pass in the explicit path to the image
-->
-{{ $numOfParams := len .Params }}
+{{ $numOfParams := sub (len .Params) 1 }}
{{ if and (ge $numOfParams 3) (not (modBool $numOfParams 2)) }}
- {{ $.Scratch.Set "path" (.Get 0) }}
+ {{ $.Scratch.Set "path" (.Get $numOfParams) }}
{{ $.Scratch.Set "structType" "shortcode" }}
{{ partial "img-path" . }}
@@ -40,17 +48,25 @@
<div class="box alt">
<div class="row uniform">
{{ $.Scratch.Set "count" 1 }}
- {{ range after 1 .Params }}
- {{ if not (modBool ($.Scratch.Get "count") 2) }}
+ {{ $.Scratch.Set "imgFile" "" }}
+ {{ range first $numOfParams .Params }}
+ {{ if eq ($.Scratch.Get "count") 1 }}
<div class="{{ . }}">
- {{ else }}
+ {{ else if eq ($.Scratch.Get "count") 2 }}
{{ if eq . "" }}
</div>
+ {{ $.Scratch.Set "imgFile" "" }}
{{ else }}
+ {{ $.Scratch.Set "imgFile" . }}
<span class="image fit">
- <img src="{{ $path }}/{{ . }}" alt="" />
+ {{ end }}
+ {{ else }}
+ {{ if ne ($.Scratch.Get "imgFile") "" }}
+ <img src='{{ $path }}/{{ $.Scratch.Get "imgFile" }}'
+ alt="{{ . }}" />
</span></div>
{{ end }}
+ {{ $.Scratch.Set "count" 0 }}
{{ end }}
{{ $.Scratch.Add "count" 1 }}
{{ end }}
diff --git a/layouts/shortcodes/img-post.html b/layouts/shortcodes/img-post.html
index 9f418ce..f2e50bb 100644
--- a/layouts/shortcodes/img-post.html
+++ b/layouts/shortcodes/img-post.html
@@ -1,6 +1,6 @@
<!-- params 2-3
Can be positional or named
-
+
position 0, name: path
Can pass in the following values:
title: will use /img/LinkTitle as the path
@@ -15,50 +15,52 @@
post: places the image centered
left: places the image to the left
right: places the image to the right
+
+ position 3, name: alt
+ Name of the alternate text for the image
-->
{{ $numOfParams := len .Params }}
-{{ if and (ge $numOfParams 2) (le $numOfParams 3) }}
+{{ if and (ge $numOfParams 2) (le $numOfParams 4) }}
<!-- Check if the Parameter is positional or named
which can handle both. If the third parameter is
not set then the default value will be post -->
{{ if .IsNamedParams }}
{{ $.Scratch.Set "path" (.Get "path") }}
{{ $.Scratch.Set "file" (.Get "file") }}
-
- {{ if eq $numOfParams 2 }}
- {{ $.Scratch.Set "type" "post" }}
- {{ else }}
- {{ $.Scratch.Set "type" (.Get "type") }}
- {{ end }}
+ {{ $.Scratch.Set "type" (.Get "type") }}
+ {{ $.Scratch.Set "alt" (.Get "alt") }}
{{ else }}
- {{ $.Scratch.Set "path" (.Get 0) }}
- {{ $.Scratch.Set "file" (.Get 1) }}
-
- {{ if eq $numOfParams 2 }}
- {{ $.Scratch.Set "type" "post" }}
- {{ else }}
- {{ $.Scratch.Set "type" (.Get 2) }}
+ {{ if ge $numOfParams 2 }}
+ {{ $.Scratch.Set "path" (.Get 0) }}
+ {{ $.Scratch.Set "file" (.Get 1) }}
+ {{ if ge $numOfParams 3 }}
+ {{ $.Scratch.Set "type" (.Get 2) }}
+ {{ end }}
+ {{ if ge $numOfParams 4 }}
+ {{ $.Scratch.Set "alt" (.Get 3) }}
+ {{ end }}
{{ end }}
{{ end }}
{{ $file := $.Scratch.Get "file" }}
{{ $type := $.Scratch.Get "type" }}
+ {{ $alt := $.Scratch.Get "alt" }}
{{ $.Scratch.Set "structType" "shortcode" }}
{{ partial "img-path" . }}
{{ $path := $.Scratch.Get "path" }}
- {{ if eq $type "post" }}
- <div class="box alt">
- <img class="center-image" src="{{ $path }}/{{ $file }}" alt="" />
- </div>
- {{ else if eq $type "left" }}
+ {{ if eq $type "left" }}
<span class="image left">
- <img src="{{ $path }}/{{ $file }}" alt="" />
+ <img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
</span>
{{ else if eq $type "right" }}
<span class="image right">
- <img src="{{ $path }}/{{ $file }}" alt="" />
+ <img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
</span>
+ {{ else }}
+ <div class="box alt">
+ <img class="center-image" src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
+ </div>
{{ end }}
{{ end }}