Skip to content

Commit 96d2874

Browse files
committed
fix(docs): Simplify an if-check in the ACF docs
1 parent 83c46fb commit 96d2874

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/v2/integrations/advanced-custom-fields.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ This is where we’ll start in PHP.
7777
```php
7878
$post = Timber::get_post();
7979

80-
if (isset($post->meta('hero_image')) && strlen($post->meta('hero_image'))) {
81-
$post->hero_image = Timber::get_image($post->meta('hero_image'));
82-
}
83-
8480
$context = Timber::context([
8581
'post' => $post,
8682
]);
@@ -93,7 +89,9 @@ Timber::render('single.twig', $context);
9389
You can now use all the above functions to transform your custom images in the same way, the format will be:
9490

9591
```twig
96-
<img src="{{ post.meta('hero_image').src | resize(500, 300) }}" />
92+
{% if post.meta('hero_image') %}
93+
<img src="{{ get_image(post.meta('hero_image')).src | resize(500, 300) }}" />
94+
{% endif %}
9795
```
9896

9997
## Gallery Field

0 commit comments

Comments
 (0)