Skip to content

Commit

Permalink
Fix adityatelange#1624. Search for the image in the page resources.
Browse files Browse the repository at this point in the history
Fixes image URL for multilingual sites when the image resource is only defined for the default language.
  • Loading branch information
valnaumov authored Dec 23, 2024
1 parent 3e53621 commit 1bdd745
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion layouts/shortcodes/figure.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }}
<img loading="lazy" src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
{{- $u := urls.Parse (.Get "src") -}}
{{- $src := $u.String -}}
{{- if not $u.IsAbs -}}
{{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
{{- $src = .RelPermalink -}}
{{- end -}}
{{- end -}}
<img loading="lazy" src="{{ $src }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
Expand Down

0 comments on commit 1bdd745

Please sign in to comment.