summaryrefslogtreecommitdiff
path: root/themes/neonxp/layouts/shortcodes/img.html
diff options
context:
space:
mode:
author2026-02-02 18:57:20 +0300
committer2026-02-02 18:57:20 +0300
commit6c4cbf8578d8a94964ca7327a7826c7c094f94fc (patch)
tree07c5dc52358b5725805a465310bbdfa1f4da82bb /themes/neonxp/layouts/shortcodes/img.html
parentБольшая чистка блога (diff)
downloadblog-6c4cbf8578d8a94964ca7327a7826c7c094f94fc.tar.gz
blog-6c4cbf8578d8a94964ca7327a7826c7c094f94fc.tar.bz2
blog-6c4cbf8578d8a94964ca7327a7826c7c094f94fc.tar.xz
blog-6c4cbf8578d8a94964ca7327a7826c7c094f94fc.zip
Fix images
Diffstat (limited to 'themes/neonxp/layouts/shortcodes/img.html')
-rw-r--r--themes/neonxp/layouts/shortcodes/img.html21
1 files changed, 21 insertions, 0 deletions
diff --git a/themes/neonxp/layouts/shortcodes/img.html b/themes/neonxp/layouts/shortcodes/img.html
new file mode 100644
index 0000000..994e30f
--- /dev/null
+++ b/themes/neonxp/layouts/shortcodes/img.html
@@ -0,0 +1,21 @@
+{{- $alt := .Get "alt" -}}
+{{- $res := .Page.Resources.Get (.Get "src") -}}
+
+{{- $ws := slice 480 800 -}}
+{{- $srcset := slice -}}
+{{- range $ws -}}
+{{- if (le . $res.Width) -}}
+{{- $w := printf "%dx" . -}}
+{{- $url := ($res.Resize $w).RelPermalink | safeURL -}}
+{{- $fmt := printf "%s %dw" $url . -}}
+{{- $srcset = $srcset | append $fmt -}}
+{{- end -}}
+{{- end -}}
+
+{{- $set := delimit $srcset "," -}}
+
+<figure>
+ <img srcset="{{ $set }}" sizes="(max-width: 480px) 480px, 100vw" src="{{ $res.RelPermalink }}" alt="{{ $alt }}"
+ height="auto" />
+ <figcaption>{{ $alt }}</figcaption>
+</figure> \ No newline at end of file