yby/shopware6-webp

为Shopware 6添加WebP支持的插件

安装: 5

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:shopware-platform-plugin

1.0.0 2021-08-17 13:03 UTC

This package is auto-updated.

Last update: 2024-09-24 14:41:05 UTC


README

https://github.com/yireo-shopware6/shopware6-webp 此扩展添加了一个名为 webp 的Twig过滤器,用于在您的Twig模板中使用。

安装

composer require yby/shopware6-webp
bin/console plugin:refresh
bin/console plugin:install --activate YbyWebp

使用方法

文件 src/Resources/views/storefront/layout/header/logo.html.twig

{% sw_extends '@Storefront/storefront/layout/header/logo.html.twig' %}

{% block layout_header_logo_image_default %}
    {% if shopware.theme['sw-logo-desktop'] %}
        <source srcset="{{ shopware.theme['sw-logo-desktop'] | webp | sw_encode_url }}"
            alt="{{ "header.logoLink"|trans|striptags }}"
            class="img-fluid header-logo-main-img"
            type="image/webp"
        />
    {% endif %}
    {{ parent() }}
{% endblock %}