SOLVED: Bricks image component dont show Custom fields image created in ACF

Bricks Version: 1.3.7
Browser: all
OS: all
URL: https://marcog146.sg-host.com/

To avoid using Gravatars I created a custom field with ACF that would allow you to set an image for post authors.

The field is called image-profile-author and as you can see from the following image it is displayed in the users profile.


In bricks I created a loop in which the latest posts in the BLOG category are displayed with the relative data of the author, such as the name and the image loaded in the author’s screen. I used the image component and told briks to load the ACF image-profile-author dynamic field, but it doesn’t load anything

Hi Paolo,
Thank you very much for your report!

To query ACF User/Author fields a little more effort is needed. The query loop assumes that your custom ACF image is included in the actual query (the post). But it is not, because it is a user field.

Have a look at the ACF documentation, there is an extra article about “User Fields”: ACF | Get values from a user

For the Bricks Loop, we have to get the Author ID before we can get the custom image. You can do this without problems inside a code element and use it instead of the image element (the code is taken from the ACF docs example):

<?php
  $author_id = get_the_author_meta('ID');
  $author_badge = get_field('your_custom_field_name', 'user_'. $author_id );
?>

<img src="<?php echo $author_badge['url']; ?>" alt="<?php echo $author_badge['alt']; ?>" />

Best regards,
timmse

2 Likes

thanks for support :slight_smile:

Thank you, it helped me a lot! Can I add this somehow to Dynamic Field?
I would like to add it to the Field part of the post.

Thank you!
Andris

Hey Andris,
What exactly do you mean by “I would like to add it to the Field part of the post.” ? Do you want to use this inside of the Posts Element?

Create a function (inside of your child themes functions.php) that contains the code from above. Then you can call it using {echo:yourFunction}.

Best regards,
timmse

1 Like

Hi @timmse
thank you for sharing the idea I also use it like that in a block code

<?php
$author_id = get_the_author_meta('ID');
$author_phone = get_field('user_phone', 'user_'. $author_id );
$author_whatsapp = get_field('user_whatsapp', 'user_'. $author_id );
$author_pic = get_field('user_pic', 'user_'. $author_id );
?>

<img src="<?php echo $author_pic['url']; ?>" alt="<?php echo $author_pic['alt']; ?>" />

<br>
<a href="tel:<?php echo $author_phone; ?>">Phone : <?php echo $author_phone; ?></a>
<br>
<a href="<?php echo $author_whatsapp; ?>">Whatsapp : <?php echo $author_whatsapp; ?></a>

but what I wonder
we really have no choice but to do it differently with bricks? Like extend Author Fields compatibility and allow us to keep control over elements under bricks

what bothers me is that I don’t have the possibility to make a div and insert an image and text link and control each element individually
what other suggestions do you have?

Not at the moment, but you can always submit a feature request on the idea board: Idea board – Bricks