Skip to content

Commit 2bed4cb

Browse files
committed
add original width and height to thumbnail pictures, for case that resize is not enabled
1 parent 9e2d807 commit 2bed4cb

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

layouts/_partials/article-list/compact.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ <h2 class="article-title">
2323
"src" $image.Permalink
2424
"alt" .Title
2525
"loading" "lazy"
26+
"width" $image.Width
27+
"height" $image.Height
2628
)
2729
) }}
2830
</div>

layouts/_partials/article-list/tile.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"src" $image.Permalink
1313
"alt" (printf "Featured image of post %s" .context.Title)
1414
"loading" "lazy"
15+
"width" $image.Width
16+
"height" $image.Height
1517
)
1618
) }}
1719
</div>

layouts/_partials/helper/thumbnail-image.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{- $width := .Width -}}
1212
{{- $height := .Height -}}
1313
{{- $resize := .Resize -}}
14-
{{- $attributes := merge (dict "width" $width "height" $height) .Attributes -}}
14+
{{- $attributes := .Attributes -}}
1515

1616
{{- if and $resize $resource (reflect.IsImageResourceProcessable $resource) $width $height -}}
1717
{{/* Create thumbnail with 1x/2x descriptors */}}
@@ -30,7 +30,7 @@
3030
{{- end -}}
3131

3232
{{- if gt (len $srcset) 0 -}}
33-
{{- $attributes = merge $attributes (dict "srcset" (delimit $srcset ", ")) -}}
33+
{{- $attributes = merge $attributes (dict "width" $width "height" $height "srcset" (delimit $srcset ", ")) -}}
3434
{{- end -}}
3535
{{- end -}}
3636

0 commit comments

Comments
 (0)