Allow changing of gallery image size
This commit is contained in:
		
							parent
							
								
									c16b3ab59f
								
							
						
					
					
						commit
						945a114f08
					
				| @ -10,7 +10,7 @@ $(function(){ | ||||
|         }); | ||||
| 
 | ||||
|         $('#gallery').nanogallery2({ | ||||
|             thumbnailHeight: 200, | ||||
|             thumbnailHeight: galleryUseHeight, | ||||
|             thumbnailWidth: 'auto', | ||||
| 
 | ||||
|             thumbnailGutterWidth: 10, | ||||
|  | ||||
| @ -1,6 +1,15 @@ | ||||
| {{- $first := true -}} | ||||
| {{- $filter := images.AutoOrient -}} | ||||
| {{- $teaser := .Resources.GetMatch "thumbnail.jpg" -}} | ||||
| {{- $galleryHeight := 200 }} | ||||
| {{- with site.Params.galleryUseHeight }} | ||||
|     {{- $galleryHeight = . | int }} | ||||
| {{- end }} | ||||
| {{- with .Page.Params.galleryUseHeight }} | ||||
|     {{- $galleryHeight = . | int }} | ||||
| {{- end }} | ||||
| {{- $galleryWidth := mul $galleryHeight 1.5 | math.Round | int -}} | ||||
| {{- $gallerySize := printf "%dx%d" $galleryWidth $galleryHeight -}} | ||||
| {{- range .Resources.ByType "image" -}} | ||||
|     {{- if not (eq $teaser .) -}} | ||||
|         {{- if not $first }}, {{ end }} | ||||
| @ -11,7 +20,7 @@ | ||||
|                 "url": "{{ .RelPermalink }}", | ||||
|                 "width": "{{ .Width }}", | ||||
|                 "height": "{{ .Height }}", | ||||
|                 "thumbnail": "{{ (.Fit "300x200").RelPermalink }}" | ||||
|                 "thumbnail": "{{ (.Fit $gallerySize).RelPermalink }}" | ||||
|             } | ||||
|         {{- end -}} | ||||
|     {{- end -}} | ||||
|  | ||||
| @ -13,4 +13,14 @@ | ||||
| <!-- <script src="{{ .Page.Site.BaseURL }}/js/main.js" defer></script> --> | ||||
| <script src="{{ (resources.Get "js/jquery.min.js").RelPermalink }}"></script> | ||||
| <script src="{{ (resources.Get "js/jquery.nanogallery2.min.js").RelPermalink }}" defer></script> | ||||
| <script> | ||||
|   {{- $galleryHeight := 200 }} | ||||
|   {{- with site.Params.galleryUseHeight }} | ||||
|     {{- $galleryHeight = . }} | ||||
|   {{- end }} | ||||
|   {{- with .Page.Params.galleryUseHeight }} | ||||
|     {{- $galleryHeight = . }} | ||||
|   {{- end }} | ||||
|   var galleryUseHeight = {{ $galleryHeight }}; | ||||
| </script> | ||||
| <script src="{{ (resources.Get "/js/gallery.js").RelPermalink }}" defer></script> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user