mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
feat: allow SVG as Hero image
This commit is contained in:
1 parent
171648c808
commit
0994df7177
2 files changed
+25
-12
No files matched your search
@@ -28,6 +28,11 @@
|
||||
/* Uncomment to standout on complicated backgrounds. */
|
||||
}
|
||||
|
||||
// Prevent `.home-section.light a` setting text to same color as button bg (the primary color)
|
||||
.wg-hero.light a.btn {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wg-hero.dark a:not(.wg-hero .btn) {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
@@ -64,21 +64,29 @@
|
||||
{{- $image = resources.Get (path.Join "media" $page.Params.hero_media) -}}
|
||||
{{- end -}}
|
||||
{{ if $image }}
|
||||
{{ $legacy_img := $image.Resize "400x" }}
|
||||
{{ $img_src := "" }}
|
||||
{{ $img_src_set := slice }}
|
||||
{{ $widths := slice 1200 800 400 }}
|
||||
{{ $isSVG := eq $image.MediaType.SubType "svg" }}
|
||||
{{ if $isSVG -}}
|
||||
|
||||
{{ range $widths }}
|
||||
{{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }}
|
||||
{{ if eq $img_src "" }}
|
||||
{{ $img_src = $src_link }}
|
||||
<img src="{{ $image.RelPermalink }}" alt="{{ $page.Title }}">
|
||||
|
||||
{{- else }}
|
||||
|
||||
{{ $legacy_img := $image.Resize "400x" }}
|
||||
{{ $img_src := "" }}
|
||||
{{ $img_src_set := slice }}
|
||||
{{ $widths := slice 1200 800 400 }}
|
||||
|
||||
{{ range $widths }}
|
||||
{{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }}
|
||||
{{ if eq $img_src "" }}
|
||||
{{ $img_src = $src_link }}
|
||||
{{ end }}
|
||||
{{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }}
|
||||
{{ end }}
|
||||
{{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }}
|
||||
{{ end }}
|
||||
{{ $img_src_set = delimit $img_src_set "," }}
|
||||
{{ $img_src_set = delimit $img_src_set "," }}
|
||||
|
||||
<img src="{{ $legacy_img.RelPermalink }}" srcset="{{ $img_src_set }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ $page.Title }}">
|
||||
<img src="{{ $legacy_img.RelPermalink }}" srcset="{{ $img_src_set }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ $page.Title }}">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user