citra-web/site/themes/citra-bs-theme/layouts/shortcodes/img.html
liushuyu 8e9b406e71 tree-wide: adapt to latest Hugo layout ...
* Use Hugo to process SCSS and images
* Use co-location page bundles
* Use Hugo/ESBuild to minify JS files
* Update NPM dependencies
2023-02-10 08:50:35 -07:00

12 lines
687 B
HTML

{{ $src := .Get "src" }}
{{ $split_src := split $src "." }}
{{ $extension := index $split_src (sub (len $split_src) 1) }}
{{ $originals := (.Page.Resources.ByType "image") }}
{{ $original := $originals.GetMatch (printf "*%s" (path.Base $src)) }}
{{ $resized := $original }}
{{- if eq $extension "png" -}}
{{ $resized_width := math.Min $original.Width 1024 }}
{{ $resized = $original.Resize (print $resized_width "x q90 jpg" ) }}
{{- end -}}
<img src="{{ $resized.Permalink }}" {{ with .Get "alt" }}alt="{{ . }}"{{ end }} class="img-responsive {{ with .Get "center" }}center-block{{ end }}" {{ with .Get "width" }}width="{{ . }}"{{end}} {{ with .Get "height" }}height="{{ . }}"{{end}} />