Skip to content

Commit fd8548e

Browse files
committed
Reversing position 2 and 3 on shortcode
Position 2 will now be the alt value. Positions 3 will be the type value.
1 parent 588edf0 commit fd8548e

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

layouts/shortcodes/img-post.html

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
<!-- params 2-3
2-
Can be positional or named
1+
<!--
2+
params 2-4
3+
Can be positional or named
34
4-
position 0, name: path
5+
position 0, name: path
56
Can pass in the following values:
67
title: will use /img/LinkTitle as the path
78
date: will use /img/Year/Month as the path
89
/path/to/img: can pass in explicit path to the image
910
10-
position 1, name: file
11+
position 1, name: file
1112
Name of the file including the file extension
1213
13-
position 2, name: type
14+
position 2, name: alt
15+
Name of the alternate text for the image
16+
17+
position 3, name: type
1418
Can pass in the following values:
15-
post: places the image centered
19+
center: places the image centered
1620
left: places the image to the left
1721
right: places the image to the right
18-
19-
position 3, name: alt
20-
Name of the alternate text for the image
2122
-->
2223
{{ $numOfParams := len .Params }}
2324
{{ if and (ge $numOfParams 2) (le $numOfParams 4) }}
2425
<!-- Check if the Parameter is positional or named
25-
which can handle both. If the third parameter is
26-
not set then the default value will be post -->
26+
which can handle both. -->
2727
{{ if .IsNamedParams }}
2828
{{ $.Scratch.Set "path" (.Get "path") }}
2929
{{ $.Scratch.Set "file" (.Get "file") }}
30-
{{ $.Scratch.Set "type" (.Get "type") }}
3130
{{ $.Scratch.Set "alt" (.Get "alt") }}
31+
{{ $.Scratch.Set "type" (.Get "type") }}
3232
{{ else }}
33-
{{ if ge $numOfParams 2 }}
34-
{{ $.Scratch.Set "path" (.Get 0) }}
35-
{{ $.Scratch.Set "file" (.Get 1) }}
36-
{{ if ge $numOfParams 3 }}
37-
{{ $.Scratch.Set "type" (.Get 2) }}
38-
{{ end }}
39-
{{ if ge $numOfParams 4 }}
40-
{{ $.Scratch.Set "alt" (.Get 3) }}
41-
{{ end }}
33+
{{ $.Scratch.Set "path" (.Get 0) }}
34+
{{ $.Scratch.Set "file" (.Get 1) }}
35+
{{ if ge $numOfParams 3 }}
36+
{{ $.Scratch.Set "alt" (.Get 2) }}
37+
{{ else }}
38+
{{ $.Scratch.Set "alt" "" }}
39+
{{ end }}
40+
{{ if ge $numOfParams 4 }}
41+
{{ $.Scratch.Set "type" (.Get 3) }}
42+
{{ else }}
43+
{{ $.Scratch.Set "type" "center" }}
4244
{{ end }}
4345
{{ end }}
4446

@@ -59,8 +61,8 @@
5961
<img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
6062
</span>
6163
{{ else }}
62-
<span class="image center-image">
64+
<p><span class="image center-image">
6365
<img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
64-
</span>
66+
</span></p>
6567
{{ end }}
6668
{{ end }}

0 commit comments

Comments
 (0)