hugo-toha/layouts/partials/helpers/get-hero.html
Patrick Magauran a2b3c7fda2
Transition to Hugo Image Processing (#173)
* Update layout to use Hugo Image Processing.

Created shortcode rimg that uses the srcset attribute to display responsive images.

* Copy Static images to assets folder.

* Add image processing to missing components + Update examples

* Fix rendering in https://themes.gohugo.io/

Co-authored-by: Emruz Hossain <emruz@appscode.com>
2020-12-31 20:55:28 +00:00

19 lines
714 B
HTML

{{/* check if there is any hero image in the same folder as the markdown file */}}
{{ $heroImage := .Page.Resources.GetMatch "hero.{jpg,png,svg}"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{/* if hero image is not provided, then use the default hero image */}}
{{ if not $heroImage }}
{{ $heroImage := resources.Get "images/default-hero.jpg"}}
{{ .Scratch.Set "heroScratch" $heroImage }}
{{ end }}
{{ $heroImage := .Scratch.Get "heroScratch" }}
{{/* resize hero image. don't resize if the image is an svg */}}
{{ if and $heroImage (ne $heroImage.MediaType.SubType "svg") }}
{{ $heroImage := $heroImage.Resize "148x" }}
{{ end }}
{{/* return the hero image */}}
{{ return $heroImage.RelPermalink }}