{{- $context := . -}}
{{- $link := .Get "link" -}}
{{- $title := .Get "title" -}}
{{- $icon := .Get "icon" -}}
{{- $subtitle := .Get "subtitle" -}}
{{- $image := .Get "image" -}}
{{- $width := 0 -}}
{{- $height := 0 -}}
{{- $imageStyle := .Get "imageStyle" -}}
{{- $tag := .Get "tag" -}}
{{- $tagType := .Get "tagType" -}}

{{/* Image processing options */}}
{{- $method := .Get "method" | default "Resize" | humanize -}}
{{- $options := .Get "options" | default "800x webp q80" -}}
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}

{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
  {{/* Retrieve the $image resource from local or global resources */}}
  {{- $processed := .Process $process -}}
  {{- $width = $processed.Width -}}
  {{- $height = $processed.Height -}}
  {{- $image = $processed.RelPermalink -}}
{{ else }}
  {{/* Otherwise, use relative link of the image */}}
  {{- if hasPrefix $image "/" -}}
    {{- $image = relURL (strings.TrimPrefix "/" $image) -}}
  {{- end -}}
{{- end -}}

{{- partial "shortcodes/card" (dict
  "page"        .Page
  "link"        $link
  "title"       $title
  "icon"        $icon
  "subtitle"    $subtitle
  "image"       $image
  "width"       $width
  "height"      $height
  "imageStyle"  $imageStyle
  "tag"         $tag
  "tagType"     $tagType
  )
-}}
