Skip to content

Commit 03bc483

Browse files
authored
Merge pull request #398 from nginxinc/image-data-grid
Img: Add data-grid support to img
2 parents 7a15f6e + 8e2ac64 commit 03bc483

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Images
3+
description: Images
4+
---
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Image Grid
3+
description: Image Grid usage
4+
---
5+
6+
The `img` shortcode has support for the `grid` attribute.
7+
The following values are supported:
8+
- `wide`
9+
- `last-third`
10+
- `first-third`
11+
- `first-two-thirds` (default)
12+
13+
``` go-template
14+
{{</*img src="hero-graphic.webp" grid="wide"*/>}}
15+
```
16+
17+
18+
## Default
19+
By default, and image will take up the first two-thirds of the grid, allowing for call out content to its right.
20+
{{< img src="hero-graphic.webp">}}
21+
{{<call-out sideline="true">}}
22+
Here is an example of a callout to the side of an image.
23+
{{</call-out>}}
24+
25+
26+
## `wide`
27+
Providing the "wide" option, will make the image take up the full grid.
28+
29+
{{< img src="hero-graphic.webp" grid="wide">}}
30+
31+
32+
## `last-third`
33+
Providing the "last-third" option, will make the image take up the last third of the grid, similar to a side call out.
34+
This makes it possible to place an image to the right of text.
35+
{{< img src="hero-graphic.webp" grid="last-third">}}

layouts/shortcodes/img.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
1+
{{- $grid := .Get "grid" | default "first-two-thirds" -}}
2+
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }} data-grid="{{$grid}}">
23
{{- $src := .Get "src" -}}
34
{{- $isSVG := strings.HasSuffix $src ".svg" -}}
45
<img class="{{ if $isSVG }}figure-svg{{ else }}figure-bitmap{{ end }}" src="{{ .Get "src" | relURL }}"
@@ -26,4 +27,4 @@ <h4>{{ . }}</h4>
2627
{{- end }}
2728
</figcaption>
2829
{{- end }}
29-
</figure>
30+
</figure>

0 commit comments

Comments
 (0)