{{- /* Usage: {{< blogPhoto "filename_relative_to_page.ext" "Alt text" >}} or {{< blogPhoto src="filename_relative_to_page.ext" alt="Alt text" >}} */ -}} {{- $imageName := false -}} {{- $alt := false -}} {{- if .IsNamedParams -}} {{- $imageName = .Get "src" | default nil -}} {{- $alt = .Get "alt" | default nil -}} {{- else -}} {{- $imageName = .Get 0 -}} {{- $alt = .Get 1 -}} {{- end -}} {{- if (eq $imageName nil) }}{{ errorf "Missing image name in %s" .Position }}{{ end -}} {{- if (eq $alt nil) }}{{ errorf "Missing alt for image %s in %s" $imageName .Position }}{{ end -}} {{- $img := .Page.Resources.GetMatch (printf "%s" $imageName) | default nil -}} {{- if (eq $img nil) }}{{ errorf "Image %s not found in %s" $imageName .Position }}{{ end -}} {{- $resizedFullHD := $img.Fit "1920x1080 q50" -}} {{- $resizedHD := $img.Fit "1280x720 q50" -}} {{- $resizedSD := $img.Fit "640x360 q50" -}} {{ $alt }}