Skip to content

mixin img.twig

Aleksey Ilyin edited this page May 6, 2022 · 5 revisions

Lazy loading of images

Usage

All arguments except src are optional

{% include 'mixin/img.twig' with {
    'src': 'https://example.com/img/my-pic.jpg',
    'id': 'attr-id-value',
    'class': 'rounded m-1',
    'title': 'Title here',
    'alt': 'Alt desc here',
    'style': 'display:block; height: 300px; width: 100%;'
} only %}

JavaScript

In the main template, include the file

{% include 'mixin/img-script.twig' %}

SRC

/src/Template/mixin/img.twig
/src/Template/mixin/img-script.twig

Clone this wiki locally