Support

Account

Home Forums ACF PRO Image not saving as URL Reply To: Image not saving as URL

  • Hi Darrenbachan,

    Here is what I’m doing, I’ve commented it below for the benefit of anyone else who might need this:

    <?php 
    $author_id = get_the_author_meta('ID');// Needed because we are outside of the Loop
    $image = get_field('author_profile_picture', 'user_'. $author_id );
    
    if ( !( $image ) ) {
     echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'quark_author_bio_avatar_size', 125 ) ); // Defaults to Gravatar if no image is uploaded, the 'quark' filters is a theme function that sets the size, if not using Quark Theme you don't need that bit
    
    } else { ?>
      <img src="<?php echo $image; ?>" width="124" height="148" alt="<?php echo $author_id->nicename; ?>" />
    <?php } ?>

    My problem was that I wasn’t specifying the author by ID in order for my template to get the right image…..once I figured that out it worked.

    You CAN still use wp_get_attachment_image( $imgID, $size ); and that method works well, it’s just that it uses some core function to add classes and styling and image sizes – great if you don’t have more specific needs.