# How to use built-in image focus method

**URL:** <https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891>\
**Category:** Questions\
**Tags:** v4\
**Created:** [November 3, 2023, 1:57pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891 "2023-11-03T13:57:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukehatfield](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukehatfield/32/386_2.png) [@lukehatfield](https://forum.getkirby.com/u/lukehatfield)\
**Post date:** [November 3, 2023, 1:57pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/1 "2023-11-03T13:57:22Z")

</div>

What is the syntax to use -\>focus() in Kirby 4? I didn’t see any template guidance on the [announcement page](https://getkirby.com/releases/4.0/image-focus).

Can’t wait to use it!

---

<div class="post-metadata">

**Author:** ![mrflix](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrflix/32/14443_2.png) [@mrflix](https://forum.getkirby.com/u/mrflix)\
**Post date:** [November 3, 2023, 2:04pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/2 "2023-11-03T14:04:17Z")

</div>

This works but it looks to complicated to be true:

```php
$image->crop(400, 300, ['crop' => $image->focus()->isEmpty() ? 'center' : $image->focus()]);

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 3, 2023, 2:38pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/3 "2023-11-03T14:38:18Z")

</div>

Focus settings should be automatically applied when you use `crop()

---

<div class="post-metadata">

**Author:** ![lukehatfield](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukehatfield/32/386_2.png) [@lukehatfield](https://forum.getkirby.com/u/lukehatfield)\
**Post date:** [November 3, 2023, 3:48pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/4 "2023-11-03T15:48:46Z")

</div>

Yes, works for me now! It may be obvious to others, but instead of just removing the old focus plugin, I also had to remove the `focus: ` field in my default image blueprint in order for the new focus to work.

---

<div class="post-metadata">

**Author:** ![eheiser](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/eheiser/32/432_2.png) [@eheiser](https://forum.getkirby.com/u/eheiser)\
**Post date:** [November 28, 2023, 5:33pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/5 "2023-11-28T17:33:45Z")

</div>

> It may be obvious to others, but instead of just removing the old focus plugin, I also had to remove the `focus: ` field in my default image blueprint in order for the new focus to work.

Thanks for that tip, was wondering why the focus point wasn’t persisting.

---

<div class="post-metadata">

**Author:** ![Shel](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@Shel](https://forum.getkirby.com/u/Shel)\
**Post date:** [December 12, 2023, 8:35am UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/6 "2023-12-12T08:35:45Z")

</div>

But we can use the focus with -\>crop() AND the -\>thumb() function (with crop=\>true for additional webp), right?

---

<div class="post-metadata">

**Author:** ![lukehatfield](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukehatfield/32/386_2.png) [@lukehatfield](https://forum.getkirby.com/u/lukehatfield)\
**Post date:** [February 8, 2024, 5:01pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/8 "2024-02-08T17:01:59Z")

</div>

@Shel thanks for mentioning. In my test it does require the `->thumb()` method in order for the `['format' => 'webp']` to work. And thumb is using my focus setting by default.

---

<div class="post-metadata">

**Author:** ![mrfreedom](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrfreedom/32/14018_2.png) [@mrfreedom](https://forum.getkirby.com/u/mrfreedom)\
**Post date:** [February 13, 2024, 5:36pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/9 "2024-02-13T17:36:22Z")

</div>

Hm, for some reason neither this

`$img->thumb(['crop' => 'true', 'width' => 800, 'height' => 800, 'format' => 'webp'])->url()`

Or this

`$image->crop(800, 800)->url()`

don’t use the focus point for me. It just crops centered as usual. I checked the .txt files for files, and the focus data is there. In the panel, the image is cropped correctly, but on the front end is still the center crop.

---

<div class="post-metadata">

**Author:** ![mrfreedom](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrfreedom/32/14018_2.png) [@mrfreedom](https://forum.getkirby.com/u/mrfreedom)\
**Post date:** [February 13, 2024, 5:46pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/10 "2024-02-13T17:46:12Z")

</div>

Rechecked: this `$image->crop(800, 800)->url()` works.

But this `$img->thumb(['crop' => 'true', 'width' => 800, 'height' => 800, 'format' => 'webp'])->url()` doesn’t. Hm…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 13, 2024, 5:47pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/11 "2024-02-13T17:47:23Z")

</div>

> [@mrfreedom](#):
>
> [‘crop’ =\> ‘true’,

You need to use a boolean, not a string “true”

---

<div class="post-metadata">

**Author:** ![mrfreedom](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrfreedom/32/14018_2.png) [@mrfreedom](https://forum.getkirby.com/u/mrfreedom)\
**Post date:** [February 13, 2024, 5:49pm UTC](https://forum.getkirby.com/t/how-to-use-built-in-image-focus-method/29891/12 "2024-02-13T17:49:48Z")

</div>

Oh dear 🫣 Yup, it works now!

Thank you, Sonja! 🙏
