|
28 | 28 |
|
29 | 29 | {% set is_jpg = src|split('.')|last == "jpg" %}
|
30 | 30 |
|
31 |
| -{# Currently 'ratio' can be string or boolean, boolean is DEPRECATED #} |
32 |
| -{% if ratio is iterable %} |
33 |
| - {% set ratio_string = ratio %} |
34 |
| -{% elseif ratio is sameas(false) or ratio is sameas(true) %} |
| 31 | +{# 'ratio' should be a string, but boolean was previously supported. Boolean is now DEPRECATED. #} |
| 32 | +{% if ratio is sameas(false) or ratio is sameas(true) %} |
35 | 33 | {% set ratio_bool = ratio %}
|
| 34 | +{% else %} |
| 35 | + {% set ratio_string = ratio %} |
| 36 | + {% set ratio_split = ratio_string|split("/") %} |
| 37 | + {% if ratio_split|length == 2 %} |
| 38 | + {% set width = ratio_split[0] %} |
| 39 | + {% set height = ratio_split[1] %} |
| 40 | + {% endif %} |
36 | 41 | {% endif %}
|
37 | 42 |
|
38 |
| -{% set useAspectRatio = useAspectRatio or ratio_bool ?? true %} |
39 |
| -{% set can_use_ratio = width > 0 and height > 0 and useAspectRatio is sameas(true) and not cover %} |
| 43 | +{% set use_ratio = useAspectRatio or ratio_bool ?? true %} |
| 44 | +{% set can_use_ratio = use_ratio is sameas(true) and ratio_string != "none" and width > 0 and height > 0 and not cover %} |
40 | 45 | {# Only JPGs allowed, PNGs can have transparency and may not look right layered over placeholder #}
|
41 | 46 | {% set can_use_placeholder = can_use_ratio or cover %}
|
42 | 47 |
|
|
109 | 114 | {% if srcset %}srcset="{{ srcset }}"{% endif %}
|
110 | 115 | {% if alt %}alt="{{ alt }}"{% endif %}
|
111 | 116 | {% if sizes %}sizes="{{ sizes }}"{% endif %}
|
112 |
| - {% if ratio_string %}ratio="{{ ratio_string }}"{% elseif not useAspectRatio %}ratio="none"{% elseif can_use_ratio %}ratio="{{ width }}/{{ height }}"{% endif %} |
| 117 | + {% if ratio_string %}ratio="{{ ratio_string }}"{% elseif not use_ratio %}ratio="none"{% elseif can_use_ratio %}ratio="{{ width }}/{{ height }}"{% endif %} |
113 | 118 | {% if placeholder_color %}placeholder-color="{{ placeholder_color }}"{% endif %}
|
114 | 119 | {% if placeholder_image %}placeholder-image="{{ placeholder_image }}"{% endif %}
|
115 | 120 | {% if zoom %}zoom{% endif %}
|
|
0 commit comments