jekyll-webp icon indicating copy to clipboard operation
jekyll-webp copied to clipboard

append_ext: true doesn't work

Open parth-verma opened this issue 4 years ago • 2 comments

With append_ext: true, it is expected that images will be generated in the format image.png.webp. However, that is not the case

parth-verma avatar Nov 18 '20 16:11 parth-verma

Agreed, this does not work for me either. It is outputting a image.webp, but not naming it correctly like it should image.png.webp

As a workaround, in my _includes/picture.html file, for the image source, I used filter | replace: '.png','.webp' " like this:

    <source srcset="{{ include.src | prepend: site.url | replace:'.png','.webp' | replace:'.jpg','.webp' }}" type="image/webp">

Full Example of my _includes/picture.html

<picture>
    <source srcset="{{ include.src | prepend: site.url | replace:'.png','.webp' | replace:'.jpg','.webp' }}" type="image/webp">
    <source srcset="{{ include.src | prepend: site.url }}" type="image/jpeg">
    <img
        src="{{ include.src | prepend: site.url }}"
        {% if include.alt %}alt="{{ include.alt }}"{% endif %}
        {% if include.title %}title="{{ include.title }}"{% endif %}
        {% if include.class %}class="{{ include.class }}"{% endif %}
        {% if include.height %}height="{{ include.height }}"{% endif %}
        {% if include.width %}width="{{ include.width }}"{% endif %}
        {% if include.style %}style="{{ include.style }}"{% endif %}
    >
</picture>

Example to use this include file:

{% include picture.html src="/assets/img/image.png" alt="My alt text!" %}

GregJacobs82 avatar Nov 19 '20 21:11 GregJacobs82

Agreed, this does not work for me either. It is outputting a image.webp, but not naming it correctly like it should image.png.webp

As a workaround, in my _includes/picture.html file, for the image source, I used filter | replace: '.png','.webp' " like this:

    <source srcset="{{ include.src | prepend: site.url | replace:'.png','.webp' | replace:'.jpg','.webp' }}" type="image/webp">

Full Example of my _includes/picture.html

<picture>
    <source srcset="{{ include.src | prepend: site.url | replace:'.png','.webp' | replace:'.jpg','.webp' }}" type="image/webp">
    <source srcset="{{ include.src | prepend: site.url }}" type="image/jpeg">
    <img
        src="{{ include.src | prepend: site.url }}"
        {% if include.alt %}alt="{{ include.alt }}"{% endif %}
        {% if include.title %}title="{{ include.title }}"{% endif %}
        {% if include.class %}class="{{ include.class }}"{% endif %}
        {% if include.height %}height="{{ include.height }}"{% endif %}
        {% if include.width %}width="{{ include.width }}"{% endif %}
        {% if include.style %}style="{{ include.style }}"{% endif %}
    >
</picture>

Example to use this include file:

{% include picture.html src="/assets/img/image.png" alt="My alt text!" %}

Neat workaround, going to use it on our webpage :)

FlameIT - Immersion Cooling

felixd avatar Feb 09 '23 12:02 felixd