@@ -34,7 +34,7 @@ page has been rendered:
3434``` twig
3535<img
3636 src="{{ asset('image/small.png') }}"
37- data-controller=" symfony-- ux-lazy-image-- lazy-image"
37+ {{ stimulus_controller(' symfony/ ux-lazy-image/ lazy-image') }}
3838 data-hd-src="{{ asset('image/large.png') }}"
3939
4040 {# Optional but avoids having a page jump when the image is loaded #}
@@ -43,13 +43,16 @@ page has been rendered:
4343/>
4444```
4545
46+ ** Note** The ` stimulus_controller() ` function comes from
47+ [ WebpackEncoreBundle v1.10] ( https://github.com/symfony/webpack-encore-bundle ) .
48+
4649Instead of using a generated thumbnail that would exist on your filesystem, you can use
4750the BlurHash algorithm to create a light, blurred, data-uri thumbnail of the image:
4851
4952``` twig
5053<img
5154 src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
52- data-controller=" symfony-- ux-lazy-image-- lazy-image"
55+ {{ stimulus_controller(' symfony/ ux-lazy-image/ lazy-image') }}
5356 data-hd-src="{{ asset('image/large.png') }}"
5457
5558 {# Using BlurHash, the size is required #}
@@ -104,7 +107,10 @@ Then in your template, add your controller to the HTML attribute:
104107``` twig
105108<img
106109 src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
107- data-controller="mylazyimage symfony--ux-lazy-image--lazy-image"
110+ {{ stimulus_controller({
111+ mylazyimage: {},
112+ 'symfony/ux-lazy-image/lazy-image: {}
113+ }) }}
108114 data-hd-src="{{ asset('image/large.png') }}"
109115
110116 {# Using BlurHash, the size is required #}
0 commit comments