imgproc.html 1.2 KB

123456789101112131415161718192021222324252627
  1. {{ $original := .Page.Resources.GetMatch (printf "**%s*" (.Get 0)) -}}
  2. {{ $command := .Get 1 -}}
  3. {{ $options := .Get 2 -}}
  4. {{ if eq $command "Fit" -}}
  5. {{ .Scratch.Set "image" ($original.Fit $options) -}}
  6. {{ else if eq $command "Resize" -}}
  7. {{ .Scratch.Set "image" ($original.Resize $options) -}}
  8. {{ else if eq $command "Fill" -}}
  9. {{ .Scratch.Set "image" ($original.Fill $options) -}}
  10. {{ else if eq $command "Crop" -}}
  11. {{ .Scratch.Set "image" ($original.Crop $options) -}}
  12. {{ else -}}
  13. {{ errorf "Invalid image processing command: Must be one of Fit, Fill, Crop or Resize." -}}
  14. {{ end -}}
  15. {{ $image := .Scratch.Get "image" -}}
  16. <figure class="card rounded p-2 td-post-card mb-4 mt-4" style="max-width: {{ add $image.Width 10 -}}px">
  17. <img class="card-img-top" src="{{- $image.RelPermalink -}}" width="{{- $image.Width -}}" height="{{- $image.Height -}}">
  18. {{ with .Inner -}}
  19. <figcaption class="card-body px-0 pt-2 pb-0">
  20. <p class="card-text">
  21. {{/* Do **not** remove this comment! It ends above html block! See https://spec.commonmark.org/0.30/#html-blocks, 7. */}}
  22. {{ . }}{{ with $image.Params.byline }}<small class="text-body-secondary"><br/>{{ . }}</small>{{ end }}
  23. </p>
  24. </figcaption>
  25. {{ end -}}
  26. </figure>