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 parts = include.path | split: '.' %}
|
||||
{% assign ext = parts.last %}
|
||||
|
||||
<figure
|
||||
{% if include.slot %}
|
||||
@ -14,13 +16,17 @@
|
||||
{% if site.imagemagick.enabled %}
|
||||
<source
|
||||
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 %}"
|
||||
type="image/webp"
|
||||
{% else %}
|
||||
srcset="{{ include.path | relative_url }}"
|
||||
{% endif %}
|
||||
{% if include.sizes %}
|
||||
sizes="{{include.sizes}}"
|
||||
{% else %}
|
||||
sizes="95vw"
|
||||
{% endif %}
|
||||
type="image/webp"
|
||||
>
|
||||
{% endif %}
|
||||
<img
|
||||
|
||||
Loading…
Reference in New Issue
Block a user