| Desktop | Mobile | | --- | --- | |  |  | Co-authored-by: stb <stb@noreply.git.hamburg.ccc.de> Reviewed-on: #73
43 lines
1.5 KiB
HTML
43 lines
1.5 KiB
HTML
{{ partial "event-design/head.html" . }}
|
|
{{- /*
|
|
Open Graph image for link previews. The theme's head/meta.html writes og:image only for the
|
|
"image" param; without it, this uses the first image in the page, a Markdown image or a
|
|
gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt text as
|
|
og:image:alt.
|
|
*/ -}}
|
|
{{- if not ($.Param "image") -}}
|
|
{{- with partialCached "first-page-image.html" . .RelPermalink -}}
|
|
{{- $alt := .alt -}}
|
|
{{- $dest := .dest -}}
|
|
{{- $url := "" -}}
|
|
{{- $width := 0 -}}
|
|
{{- $height := 0 -}}
|
|
{{- $resource := .resource -}}
|
|
{{- if findRE `^https?://` $dest -}}
|
|
{{- $url = $dest -}}
|
|
{{- end -}}
|
|
{{- with $resource -}}
|
|
{{- $image := . -}}
|
|
{{- if and (eq .ResourceType "image") (ne .MediaType.SubType "svg") -}}
|
|
{{- /* Turned as its EXIF orientation says; Hugo doesn't do that when it resizes. */ -}}
|
|
{{- $image = .Filter images.AutoOrient -}}
|
|
{{- if gt $image.Width 1200 }}{{ $image = $image.Resize "1200x" }}{{ end -}}
|
|
{{- $width = $image.Width -}}
|
|
{{- $height = $image.Height -}}
|
|
{{- end -}}
|
|
{{- $url = $image.Permalink -}}
|
|
{{- end -}}
|
|
{{- with $url }}
|
|
<meta property="og:image" content="{{ . }}">
|
|
{{- with $width }}
|
|
<meta property="og:image:width" content="{{ . }}">
|
|
<meta property="og:image:height" content="{{ $height }}">
|
|
{{- end }}
|
|
{{- with $alt }}
|
|
<meta property="og:image:alt" content="{{ . }}">
|
|
{{- end }}
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|