Prepare thumbnails of all images in the photo post
Add <img> tags for all thumbnails to the photos list entry. I'm hoping with lazy loading and some JavaScript this will not be terrible! Break the logic for preparing a thumbnail into a separate helper partial template so it can be reused.
This commit is contained in:
parent
da994bd6b7
commit
afb59e7862
3 changed files with 85 additions and 6 deletions
28
layouts/partials/photos/thumbnail_for_list.html
Normal file
28
layouts/partials/photos/thumbnail_for_list.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
{{ $thumbnailResource := .Image }}
|
||||
|
||||
{{ $orientation := partial "images/orientation_angle.html" $thumbnailResource }}
|
||||
|
||||
{{ $targetWidth := 0 }}
|
||||
{{ if isset . "Width" }}
|
||||
{{ $targetWidth = .Width }}
|
||||
{{ else }}
|
||||
{{ $targetWidth = $thumbnailResource.Width }}
|
||||
{{ end }}
|
||||
|
||||
{{ $targetHeight := 0 }}
|
||||
{{ if isset . "Height" }}
|
||||
{{ $targetHeight = .Height }}
|
||||
{{ else }}
|
||||
{{ $targetHeight = $thumbnailResource.Height }}
|
||||
{{ end }}
|
||||
|
||||
{{ $thumbnail := false }}
|
||||
{{ if not (and (eq $orientation 0)
|
||||
(eq $targetWidth $thumbnailResource.Width)
|
||||
(eq $targetHeight $thumbnailResource.Height)) }}
|
||||
{{ $thumbnail = $thumbnailResource.Fit (printf "%dx%d r%d" $targetWidth $targetHeight (sub 360 $orientation)) }}
|
||||
{{ else }}
|
||||
{{ $thumbnail = $thumbnailResource }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $thumbnail }}
|
Loading…
Add table
Add a link
Reference in a new issue