diff options
| author | Reorx <novoreorx@gmail.com> | 2022-07-01 11:47:10 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-07-01 11:47:10 +0800 |
| commit | 61452c190b57ed2c1246723e7fd1575ac4bf5a23 (patch) | |
| tree | 322d4d3b695a6e364031462b9a380259a5fbfcd5 | |
| parent | 3eaeb0f6c7db592c54384251e5a162452599854c (diff) | |
add figure-img-size shortcode
for controlling image size with <figure>
| -rw-r--r-- | assets/css/common/main.css | 4 | ||||
| -rw-r--r-- | layouts/shortcodes/figure-img-size.html | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/assets/css/common/main.css b/assets/css/common/main.css index 5bf1d3b..e02851b 100644 --- a/assets/css/common/main.css +++ b/assets/css/common/main.css @@ -224,6 +224,10 @@ figure > img { text-align: center; } +.image-size-control { + margin-left: auto; + margin-right: auto; +} .image-size-control > img { width: inherit; height: inherit; diff --git a/layouts/shortcodes/figure-img-size.html b/layouts/shortcodes/figure-img-size.html new file mode 100644 index 0000000..62c9f20 --- /dev/null +++ b/layouts/shortcodes/figure-img-size.html @@ -0,0 +1,12 @@ +{{- $width := .Get 1 }} +{{- $height := .Get 2 }} +<figure class="center align-center"> + <div class="image-size-control" style=" +{{- with $width }}max-width: {{ . }};{{ end -}} +{{- with $height }}max-height: {{ . }};{{ end -}} +"> + {{ .Page.RenderString .Inner }} + </div> + + <figcaption><p>{{ .Get 0 | markdownify }}</p></figcaption> +</figure> |
