How can I change this so it uses thumbs?
The image inside the snippet is as follows
snippets/editor/image.php
<img src="<?= $attrs->src() . '/tr:pr-live' ?>" alt="<?= $attrs->alt() ?>">
But how can I do this?
<img src="<?= $attrs->thumb(['bl' => 100, 'q' => 10])->src() ?>" data-src="<?= $attrs->thumb()->src() ?>" alt="<?= $attrs->alt() ?>" class="j-lazy">
$image = $attrs->id()->toFile();
gives you the image. So you can turn this into a thumb:
<?php if ($image) : ?>
img src="<?= $image->thumb(['bl' => 100, 'q' => 10])->src() ?>" data-src="<?= $image->thumb()->src() ?>" alt="<?= $image->alt() ?>" class="j-lazy">
<?php endif ?>
Thanks - slight modification to your image tag and it works.
url()
not src()
and need to use the $attrs->alt()
otherwise the alt text won’t come through, but other than that it works. Thank you.
<img src="<?= $image->thumb(['bl' => 100, 'q' => 10])->url() ?>" data-src="<?= $image->thumb()->url() ?>" alt="<?= $attrs->alt() ?>" class="j-lazy">