fix: resize og:image
This commit is contained in:
parent
e326cdfc95
commit
da18fe3b68
2 changed files with 4 additions and 10 deletions
|
@ -13,19 +13,14 @@
|
||||||
<!-- Is an external image -->
|
<!-- Is an external image -->
|
||||||
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $pageResourceImage := resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
{{ $pageResourceImage := (.Context.Resources.GetMatch ($imageValue | safeURL)).Fill "300x300 center" }}
|
||||||
|
|
||||||
{{ if $pageResourceImage }}
|
{{ if $pageResourceImage }}
|
||||||
<!-- If image is found under page bundle -->
|
<!-- If image is found under page bundle -->
|
||||||
{{ $result = merge $result (dict "permalink" $pageResourceImage.RelPermalink) }}
|
{{ $result = merge $result (dict "permalink" $pageResourceImage.RelPermalink) }}
|
||||||
|
|
||||||
<!-- Disable SVG image processing, not supported by Hugo -->
|
|
||||||
{{ if ne (path.Ext $imageValue) ".svg" }}
|
|
||||||
{{ $result = merge $result (dict "resource" $pageResourceImage) }}
|
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<!-- Can not find the image under page bundle. Could be a relative linked image -->
|
<!-- Can not find the image under page bundle. Could be a relative linked image -->
|
||||||
{{ $result = merge $result (dict "permalink" (relURL $imageValue)) }}
|
{{ $result = merge $result (dict "permalink" (printf "%s" (relURL $imageValue))) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -42,8 +37,7 @@
|
||||||
|
|
||||||
{{ if $siteResourceImage }}
|
{{ if $siteResourceImage }}
|
||||||
<!-- Try search image under site's assets folder -->
|
<!-- Try search image under site's assets folder -->
|
||||||
{{ $result = merge $result (dict "permalink" $siteResourceImage.RelPermalink) }}
|
{{ $result = merge $result (dict "permalink" ($siteResourceImage.Fill "300x300 center").RelPermalink) }}
|
||||||
{{ $result = merge $result (dict "resource" $siteResourceImage) }}
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<!-- Can not find the image -->
|
<!-- Can not find the image -->
|
||||||
{{ errorf "Failed loading image: %q" $defaultImageSetting.src }}
|
{{ errorf "Failed loading image: %q" $defaultImageSetting.src }}
|
||||||
|
|
|
@ -39,6 +39,6 @@
|
||||||
|
|
||||||
{{ $image := partial "helpers/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" }}
|
{{ $image := partial "helpers/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" }}
|
||||||
{{ if $image.exists }}
|
{{ if $image.exists }}
|
||||||
<meta property="og:image" content="{{ absURL $image.permalink }}" />
|
<meta property="og:image" content="{{ $image.permalink }}" />
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue