a new start
This commit is contained in:
29
_includes/components/hy-img.html
Normal file
29
_includes/components/hy-img.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% assign sources = '' %}
|
||||
{% if include.img.src or include.img.path %}
|
||||
{% assign srcset = null %}
|
||||
|
||||
{% if include.img.srcset %}
|
||||
{% capture srcset %}{% for hash in include.img.srcset %}{% assign tmp = hash[1] %}{% include_cached smart-url url=tmp %} {{ hash[0] }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
|
||||
{% endif %}
|
||||
|
||||
{% assign src = include.img.src | default:include.img.path %}
|
||||
{% capture sources %}
|
||||
src="{% include_cached smart-url url=src %}"
|
||||
{% if srcset %}srcset="{{ srcset | strip }}"{% endif %}
|
||||
{% if include.sizes %}sizes="{{ include.sizes | replace:' ', '' }}"{% endif %}
|
||||
{% endcapture %}
|
||||
{% else %}
|
||||
{% capture sources %}
|
||||
src="{% include_cached smart-url url=include.img %}"
|
||||
{% endcapture %}
|
||||
{% endif %}
|
||||
|
||||
<img
|
||||
{{ sources }}
|
||||
{% if include.alt %}alt="{{ include.alt }}"{% endif %}
|
||||
{% if include.class %}class="{{ include.class }}"{% endif %}
|
||||
{% if include.property %}property="{{ include.property }}"{% endif %}
|
||||
{% if include.width %}width="{{ include.width }}"{% endif %}
|
||||
{% if include.height %}height="{{ include.height }}"{% endif %}
|
||||
{% if include.width and include.height %}loading="lazy"{% endif %}
|
||||
/>
|
||||
Reference in New Issue
Block a user