Kirby

Is it possible to blur on crop image?

Hi, I’m try to made lazy load images, and my code is looks like this

<picture>
<source 
    	media="(min-width: 1200px)" 
    	data-srcset="<?= $img->crop(150, 100)->url() ?> 1x, <?= $img->crop(600, 400)->url() ?> 2x">
<source 
    	media="(min-width: 800px)" 
    	data-srcset="<?= $img->crop(150, 100)->url() ?> 1x, <?= $img->crop(600, 400)->url() ?> 2x">
    	<img alt="<?= $game->title() ?>" class="card-img-top lazy" data-src="<?= $img->crop(300, 200)->url() ?>">
</picture>

Is there some way, how can I use blur() here $img->crop(150, 100)->url()

I’m try
$img->crop(150, 100)->blur()->url() but it is return empty src

also Im try to

create $img_blur = $img->blur(); and this also return error for me…

You can use the thumb() method instead: https://getkirby.com/docs/reference/objects/file/thumb

1 Like

Thanks! It helps!