可缩放的图片

使用懒加载图片快速加载

首先加载小尺寸或 模糊 的图片,然后在页面加载完成后加载真图。

composer require symfony/ux-lazy-image
<img
    src="{{ data_uri_thumbnail(legosFilePath, 40, 30) }}"
    data-controller="symfony--ux-lazy-image--lazy-image"
    data-symfony--ux-lazy-image--lazy-image-src-value="{{ asset('images/legos.jpg') }}"
    alt="A blurhash image that is replaced by the real image on load"
    width="578"
    height="275"
    style="border-radius: 5px;"
>
首先加载小尺寸(或模糊)的图片
真图(大尺寸图片)在页面加载后下载
A blurhash image that is replaced by the real image on load

安装它

$ composer require symfony/ux-lazy-image