diff options
author | uPagge <git@upagge.ru> | 2021-02-27 13:30:27 +0300 |
---|---|---|
committer | uPagge <git@upagge.ru> | 2021-02-27 13:30:27 +0300 |
commit | 344877cf8ba2d26f396b9d0d6e2f582c66aad722 (patch) | |
tree | b032b0e5e99601299c2d25380a59fb9c9f03cf39 /layouts | |
parent | d9178d69d44f65ab7bee8569ae55c9985493649d (diff) |
image resize
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-image.html | 12 | ||||
-rw-r--r-- | layouts/posts/single.html | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 07f34c2..312139c 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -6,15 +6,23 @@ {{- end -}} {{ $imageOriginal := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) }} +{{ if $imageOriginal }} +{{ if lt 1600 $imageOriginal.Width }} +{{ $imageOriginal = ($imageOriginal.Resize "1600x q100").Permalink }} +{{ end }} +{{ else }} +{{ $imageOriginal = .Destination }} +{{ end }} + <div style="text-align: center"> {{- if $figcap -}} <figure> - {{- dict "Src" .Destination "Title" $figcap "Alt" $alt "Caption" $caption "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}} + {{- dict "Src" $imageOriginal "Title" $figcap "Alt" $alt "Caption" $caption "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}} <figcaption class="image-caption"> {{- $figcap | safeHTML -}} </figcaption> </figure> {{- else -}} -{{- dict "Src" .Destination "Title" (path.Base .Destination) "Alt" $alt "Resources" .Page.Resources | partial "plugin/image.html" -}} +{{- dict "Src" $imageOriginal "Title" (path.Base .Destination) "Alt" $alt "Resources" .Page.Resources | partial "plugin/image.html" -}} {{- end -}} </div> diff --git a/layouts/posts/single.html b/layouts/posts/single.html index df689c9..881a41c 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -56,7 +56,11 @@ {{- $heroImage := "" -}} {{- with .Resources.GetMatch "featured-image" -}} - {{- $heroImage = (.Resize "1000x q100").Permalink -}} + {{- if lt 1600 .Width -}} + {{- $heroImage = (.Resize "1600x q100").Permalink -}} + {{- else -}} + {{- $heroImage = .Permalink -}} + {{- end -}} {{- end -}} <div class="post-hero-grid"> @@ -113,7 +117,11 @@ {{- $fullImage := $image -}} {{- if eq $pageTheme "full" -}} {{- with $.Resources.GetMatch "featured-image" -}} - {{- $fullImage = (.Resize "1500x q100").Permalink -}} + {{- if lt 1600 .Width -}} + {{- $fullImage = (.Resize "1600x q100").Permalink -}} + {{- else -}} + {{- $fullImage = .Permalink -}} + {{- end -}} {{- end -}} {{- end -}} |