Add a shortcode to embed a photo post in a blog post
This commit is contained in:
parent
e7b2cb493a
commit
57947282ce
2 changed files with 16 additions and 0 deletions
8
layouts/partials/images/photo_thumbnail.html
Normal file
8
layouts/partials/images/photo_thumbnail.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{- $thumbnailResource := .Resources.GetMatch (index .Page.Params "thumbnail")
|
||||
| default (index (.Page.Resources.ByType "image") 0) -}}
|
||||
{{- if not $thumbnailResource -}}
|
||||
{{- errorf "No thumbnail available for %s" .Page.Permalink }}
|
||||
{{- end -}}
|
||||
{{- $orientation := partial "images/orientation_angle.html" $thumbnailResource -}}
|
||||
{{- $thumbnail := $thumbnailResource.Fit (printf "%dx%d r%d" .Width .Height (sub 360 $orientation)) -}}
|
||||
{{ return $thumbnail }}
|
8
layouts/shortcodes/photo.html
Normal file
8
layouts/shortcodes/photo.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{- with $photoPage := $.Page.GetPage (printf "photos/%s" (.Get 0)) -}}
|
||||
{{- $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
|
||||
<img src="{{ $thumbnail.RelPermalink }}" {{/*{{ with $altText }}alt="{{ . }}"{{ end }}*/}}>
|
||||
</a>
|
||||
{{- else -}}
|
||||
{{- errorf "No page matching '%s'" (.Get 0) -}}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue