Fixed .webp src creation for svg and other files (#2698)
Added a default srcset in case extension is other than the following: - .jpg - .jpeg - .png - .tiff - .gif fixed #2660
This commit is contained in:
parent
8e9cf03ee9
commit
046545983f
@ -1,4 +1,6 @@
|
|||||||
{% assign img_path = include.path | remove: '.jpg' | remove: '.jpeg' | remove: '.png' | remove: '.tiff' | remove: '.gif' %}
|
{% assign img_path = include.path | remove: '.jpg' | remove: '.jpeg' | remove: '.png' | remove: '.tiff' | remove: '.gif' %}
|
||||||
|
{% assign parts = include.path | split: '.' %}
|
||||||
|
{% assign ext = parts.last %}
|
||||||
|
|
||||||
<figure
|
<figure
|
||||||
{% if include.slot %}
|
{% if include.slot %}
|
||||||
@ -14,13 +16,17 @@
|
|||||||
{% if site.imagemagick.enabled %}
|
{% if site.imagemagick.enabled %}
|
||||||
<source
|
<source
|
||||||
class="responsive-img-srcset"
|
class="responsive-img-srcset"
|
||||||
|
{% if ext == '.jpg' or ext == '.jpeg' or ext == '.png' or ext == '.tiff' or ext == '.gif' %}
|
||||||
srcset="{% for i in site.imagemagick.widths %}{{ img_path | relative_url }}-{{ i }}.webp {{i}}w,{% endfor %}"
|
srcset="{% for i in site.imagemagick.widths %}{{ img_path | relative_url }}-{{ i }}.webp {{i}}w,{% endfor %}"
|
||||||
|
type="image/webp"
|
||||||
|
{% else %}
|
||||||
|
srcset="{{ include.path | relative_url }}"
|
||||||
|
{% endif %}
|
||||||
{% if include.sizes %}
|
{% if include.sizes %}
|
||||||
sizes="{{include.sizes}}"
|
sizes="{{include.sizes}}"
|
||||||
{% else %}
|
{% else %}
|
||||||
sizes="95vw"
|
sizes="95vw"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
type="image/webp"
|
|
||||||
>
|
>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<img
|
<img
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user