Allow the caller of the figures/image shortcode to skip image processing via the shouldResize argument
This commit is contained in:
		
							parent
							
								
									85ed759a3a
								
							
						
					
					
						commit
						e18453dac0
					
				
					 1 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
{{- $imgs := slice -}}
 | 
			
		||||
{{- $class := .Get "class" -}}
 | 
			
		||||
{{- $shouldResize := .Get "shouldResize" | default true -}}
 | 
			
		||||
{{- $shouldShowTitle := (.Get "shouldShowTitle") | default true -}}
 | 
			
		||||
 | 
			
		||||
{{- if .Get "name" -}}
 | 
			
		||||
  {{- $imgs = $imgs | append (.Page.Resources.GetMatch (.Get "name")) -}}
 | 
			
		||||
| 
						 | 
				
			
			@ -10,21 +13,20 @@
 | 
			
		|||
  {{ errorf "Missing name or names parameter to figures/image" }}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{- $class := .Get "class" -}}
 | 
			
		||||
 | 
			
		||||
{{- if lt (len $imgs) 0 -}}
 | 
			
		||||
  {{ errorf "No images found for name(s) parameter" }}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{- $shouldShowTitle := (.Get "shouldShowTitle") | default true -}}
 | 
			
		||||
 | 
			
		||||
<figure {{with $class }}class="{{ . }}"{{ end }}>
 | 
			
		||||
<figure {{ with $class }}class="{{ . }}"{{ end }}>
 | 
			
		||||
  <div class=container>
 | 
			
		||||
    {{ range $img := $imgs -}}
 | 
			
		||||
      {{- $resizedImg := $img.Fit "1280x1280" -}}
 | 
			
		||||
    {{ range $img := $imgs }}
 | 
			
		||||
      {{- $linkedImg := $img -}}
 | 
			
		||||
      {{- if $shouldResize -}}
 | 
			
		||||
        {{ $linkedImg = $img.Fit "1280x1280" }}
 | 
			
		||||
      {{- end -}}
 | 
			
		||||
      {{- $altText := $img.Params.alt | default $img.Title -}}
 | 
			
		||||
      <a href="{{ $img.RelPermalink }}">
 | 
			
		||||
        <img src="{{ $resizedImg.RelPermalink }}"
 | 
			
		||||
        <img src="{{ $linkedImg.RelPermalink }}"
 | 
			
		||||
          {{- with $altText }} alt="{{ . }}"{{- end }}
 | 
			
		||||
          {{- with $img.Title }} title="{{ . }}"{{- end }}>
 | 
			
		||||
      </a>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue