|
21 | 21 | {{- end -}}
|
22 | 22 | {{- end -}}
|
23 | 23 |
|
| 24 | +{{- $different_ratios := and $has_mobile $has_desktop -}} |
| 25 | + |
| 26 | + |
24 | 27 | <figure class="c-image{{ range $modifier }} c-image--{{ . }}{{ end }}{{ with $class_name }} {{ . }}{{end}}">
|
25 |
| - {{- with $image_mobile -}} |
26 |
| - {{- partial "utils/asset" (dict |
27 |
| - "globals" $globals |
28 |
| - "context" . |
29 |
| - "options" (merge $params (dict |
30 |
| - "class_name" (print "c-image__asset" (cond $has_desktop " md:u-hidden" "") ) |
31 |
| - )) |
32 |
| - ) -}} |
33 |
| - {{- end -}} |
34 |
| - {{- with $image_desktop -}} |
35 |
| - {{- partial "utils/asset" (dict |
36 |
| - "globals" $globals |
37 |
| - "context" . |
38 |
| - "options" (merge $params (dict |
39 |
| - "class_name" (print "c-image__asset" (cond $has_mobile " -md:u-hidden" "") ) |
40 |
| - )) |
41 |
| - ) -}} |
| 28 | + {{ if $different_ratios }} |
| 29 | + <picture class="c-image__asset"> |
| 30 | + {{- partial "utils/asset/image/sources" (dict |
| 31 | + "globals" $globals |
| 32 | + "context" $image_mobile |
| 33 | + "options" (merge $params (dict |
| 34 | + "media" "(max-width: 767px)" |
| 35 | + )) |
| 36 | + ) -}} |
| 37 | + {{- partial "utils/asset/image/sources" (dict |
| 38 | + "globals" $globals |
| 39 | + "context" $image_desktop |
| 40 | + "options" (merge $params (dict |
| 41 | + "media" "(min-width: 768px)" |
| 42 | + )) |
| 43 | + ) -}} |
| 44 | + {{- partial "utils/asset/image/img" (dict |
| 45 | + "globals" $globals |
| 46 | + "context" $image_desktop |
| 47 | + "options" $params |
| 48 | + ) -}} |
| 49 | + </picture> |
| 50 | + {{ else }} |
| 51 | + {{- with $image_mobile -}} |
| 52 | + {{- partial "utils/asset" (dict |
| 53 | + "globals" $globals |
| 54 | + "context" . |
| 55 | + "options" (merge $params (dict |
| 56 | + "class_name" (print "c-image__asset" (cond $has_desktop " md:u-hidden" "") ) |
| 57 | + )) |
| 58 | + ) -}} |
| 59 | + {{- end -}} |
| 60 | + {{- with $image_desktop -}} |
| 61 | + {{- partial "utils/asset" (dict |
| 62 | + "globals" $globals |
| 63 | + "context" . |
| 64 | + "options" (merge $params (dict |
| 65 | + "class_name" (print "c-image__asset" (cond $has_mobile " -md:u-hidden" "") ) |
| 66 | + )) |
| 67 | + ) -}} |
| 68 | + {{- end -}} |
42 | 69 | {{- end -}}
|
43 | 70 | {{- with $caption -}}
|
44 | 71 | <figcaption>{{ . }}</figcaption>
|
|
0 commit comments