Debian Codegraph @

docs/layouts/_shortcodes/imgproc.html

raw
1 {{/*
2 Renders the given image using the given process specification.
3
4 @param {string} path The path to the image, either a page resource or a global resource.
5 @param {string} spec The image processing specification.
6 @param {string} alt The alt attribute of the img element.
7
8 @example {{< imgproc path="sunset.jpg" spec="resize 300x" alt="A sunset" >}}
9 */}}
10
11 {{- with $.Get "path" }}
12 {{- with $i := or ($.Page.Resources.Get .) (resources.Get .) }}
13 {{- with $spec := $.Get "spec" }}
14 {{- with $i.Process . }}
15 <figure>
16 <img
17 src="{{ .RelPermalink }}"
18 width="{{ .Width }}"
19 height="{{ .Height }}"
20 alt="{{ $.Get `alt` }}">
21 <figcaption class="not-prose text-sm">
22 {{- with $.Inner }}
23 {{ . }}
24 {{- else }}
25 {{ $spec }}
26 {{- end }}
27 </figcaption>
28 </figure>
29 {{- end }}
30 {{- else }}
31 {{- errorf "The %q shortcode requires a 'spec' argument containing the image processing specification. See %s" $.Name $.Position }}
32 {{- end }}
33 {{- else }}
34 {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
35 {{- end }}
36 {{- else }}
37 {{- errorf "The %q shortcode requires a 'path' argument indicating the image path. The image must be a page resource or a global resource. See %s" $.Name $.Position }}
38 {{- end }}