Merge remote-tracking branch 'origin/photo-shortcode' into gs/photo-shortcode
This commit is contained in:
commit
226638b7c5
@ -5,7 +5,12 @@ Usage:
|
|||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
{{< blogPhoto src="filename_relative_to_page.ext" alt="Alt text" >}}
|
{{< blogPhoto src="filename_relative_to_page.ext" alt="Alt text" … >}}
|
||||||
|
|
||||||
|
where possible named params are:
|
||||||
|
* src - path to the image in page bundle
|
||||||
|
* alt - textual description of the image, the <img> alt attribute
|
||||||
|
* caption (optional) - the caption displayed under the image, defaults to `alt`. Set to false to disable caption rendering
|
||||||
|
|
||||||
*/ -}}
|
*/ -}}
|
||||||
{{- $imageName := false -}}
|
{{- $imageName := false -}}
|
||||||
@ -19,6 +24,7 @@ or
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if (eq $imageName nil) }}{{ errorf "Missing image name in %s" .Position }}{{ end -}}
|
{{- if (eq $imageName nil) }}{{ errorf "Missing image name in %s" .Position }}{{ end -}}
|
||||||
{{- if (eq $alt nil) }}{{ errorf "Missing alt for image %s in %s" $imageName .Position }}{{ end -}}
|
{{- if (eq $alt nil) }}{{ errorf "Missing alt for image %s in %s" $imageName .Position }}{{ end -}}
|
||||||
|
{{- $caption := cond (eq (.Get "caption") false) false (default $alt (.Get "caption")) -}}
|
||||||
|
|
||||||
{{- $img := .Page.Resources.GetMatch $imageName | default nil -}}
|
{{- $img := .Page.Resources.GetMatch $imageName | default nil -}}
|
||||||
{{- if (eq $img nil) }}{{ errorf "Image %s not found in %s" $imageName .Position }}{{ end -}}
|
{{- if (eq $img nil) }}{{ errorf "Image %s not found in %s" $imageName .Position }}{{ end -}}
|
||||||
@ -39,4 +45,7 @@ or
|
|||||||
{{- $largest = $compressed -}}
|
{{- $largest = $compressed -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<img src="{{ $largest.RelPermalink }}" alt="{{ $alt }}" srcset="{{ delimit $srcset ", " }}" sizes="(orientation: portrait) 100vw, 50vw">
|
<figure>
|
||||||
|
<img src="{{ $largest.RelPermalink }}" alt="{{ $alt }}" srcset="{{ delimit $srcset ", " }}" sizes="(orientation: portrait) 100vw, 50vw">
|
||||||
|
{{ if (ne $caption false) }}<figcaption>{{ $caption }}</figcaption>{{ end }}
|
||||||
|
</figure>
|
||||||
|
Loading…
Reference in New Issue
Block a user