Support

Account

Home Forums Front-end Issues User field image not displaying

Helping

User field image not displaying

  • Hi there!

    I’m having a little trouble getting the User field to display the image, everything else is working perfectly well and it’s even pulling through the url when i check in the inspector however when i hover over the url i get a popup saying ‘could not load the image’.

    Since everything else it working I’m thinking this might be a gravatar or possibly a browser issue.

    Code snippet included below ::

                  $nomInfo = get_sub_field('staff_member'); ?>
                  
                  <div class="nomination-block col-12 col-md-4 text-center">
                    <h3><?php the_sub_field('nom_ranking'); ?></h3>
                    <img src="<?php echo esc_attr($nomInfo['user_avatar']); ?>" alt="author-avatar" />
                    <h3><?php echo $nomInfo['display_name']; ?></h3>
                    <p><?php the_sub_field('staff_content');?></p>
                  </div>
    

    If anyone has any insight into this I’d be really grateful!

  • This looks like a repeater, are you using the user ID in the if and while part of the repeater call?
    Is the field set to return an array or URL?

    But I think the issue is this:
    <img src="<?php echo esc_attr($nomInfo['user_avatar']); ?>" alt="author-avatar" />
    Should be this:
    <img src="<?php echo esc_url($nomInfo['url']); ?>" alt="<?php echo esc_attr($nomInfo['alt']); ?>" />

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.