Skip to content

Commit

Permalink
fix(docs): Simplify an if-check in the ACF docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Feb 9, 2024
1 parent 83c46fb commit 96d2874
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/v2/integrations/advanced-custom-fields.md
Expand Up @@ -77,10 +77,6 @@ This is where we’ll start in PHP.
```php
$post = Timber::get_post();

if (isset($post->meta('hero_image')) && strlen($post->meta('hero_image'))) {
$post->hero_image = Timber::get_image($post->meta('hero_image'));
}

$context = Timber::context([
'post' => $post,
]);
Expand All @@ -93,7 +89,9 @@ Timber::render('single.twig', $context);
You can now use all the above functions to transform your custom images in the same way, the format will be:

```twig
<img src="{{ post.meta('hero_image').src | resize(500, 300) }}" />
{% if post.meta('hero_image') %}
<img src="{{ get_image(post.meta('hero_image')).src | resize(500, 300) }}" />
{% endif %}
```

## Gallery Field
Expand Down

0 comments on commit 96d2874

Please sign in to comment.