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