Support

Account

Home Forums ACF PRO How to retrieve image field within a user field query? Reply To: How to retrieve image field within a user field query?

  • Hi @miguelripoll

    My guess is that you’ve set the return value of the image field to “Image object” (that’s the default setting). That means that the $pic variable will be an array of the attachments values such as url, sizes, alt etc.

    Based on the way you print everything now you’d first need to setup the $pic variable as an actual img tag.

    Something like:

    
    <?php
    $pic_object = get_field( 'pic', 'user_' . $value['ID'] ); 
    $pic = '<img src="' . $pic_object['url'] . '" alt="' . $pic_object['alt'] . '" />';
    ?>