-
Notifications
You must be signed in to change notification settings - Fork 0
twig
onadrog edited this page Sep 14, 2021
·
2 revisions
{% extends 'base.html.twig' %}
{% block body %}
{{ image_converter_img(foo) }}
{% endblock %}
Will return an <img>
tag or a <picure>
tag as follow:
<!-- Example without the original file ('keep_original' config vars set to false) -->
<body>
<img
class="image_converter_img"
alt="the alt name provided"
src="/uploads/media/foo.webp"
width="150"
height="150"
loading="lazy"
/>
</body>
<!-- Example with the original file ('keep_original' config vars set to true) -->
<body>
<picture>
<source srcset="/uploads/media/foo.webp" type="image/webp">
<img
class="image_converter_img"
alt="the alt name provided"
src="/uploads/media/foo.png"
width="150"
height="150"
loading="lazy"
/>
<picture>
</body>
{% extends 'base.html.twig' %}
{% block body %}
{{ image_converter_img(foo, false, 'my_class_name', 'file') }}
{% endblock %}
Will return an image tag as follow:
<body>
<img
class="my_class_name"
alt="the alt name provided"
src="/uploads/media/foo.webp"
width="150"
height="150"
/>
</body>
Parameter | Type | Required | Default |
---|---|---|---|
$val |
object | true | null |
$lazyload |
bool | false | true |
$className |
string | false | image_converter_img |
$property |
string | false | file |
image_converter_img(object $value,bool $lazyLoad = true,string $classname = 'image_converter_img', string $property='file'): string
If you have changed the default entity property $file
where the ImageUploadProperties
is mapped on you MUST pass this new property new to the extension.