Browse Source

Fix a bug with the img shortcode.

Syfaro 1 month ago
parent
commit
dca219ba91
1 changed files with 15 additions and 5 deletions
  1. 15
    5
      layouts/shortcodes/img.html

+ 15
- 5
layouts/shortcodes/img.html View File

@@ -1,6 +1,16 @@
1
-{{ $img := $.Page.Resources.GetMatch (.Get 0)}}
1
+{{ $images := .Page.Resources.ByType "image" }}
2 2
 
3
-<figure>
4
-	<img src="{{ $img.RelPermalink }}" alt="(.Get 1)" />
5
-	<figcaption>{{ .Get 1 }}</figcaption>
6
-</figure>
3
+{{ $img := $images.GetMatch (.Get 0)}}
4
+
5
+{{ if ne $img.MediaType.SubType "svg" }}
6
+	{{ $img = $img.Resize "800x" }}
7
+{{ end }}
8
+
9
+{{ with (.Get 1) }}
10
+	<figure>
11
+		<img src="{{ $img.RelPermalink }}" alt="{{ . }}" />
12
+		<figcaption>{{ . }}</figcaption>
13
+	</figure>
14
+{{ else }}
15
+	<img src="{{ $img.RelPermalink }}" />
16
+{{ end }}

Loading…
Cancel
Save