Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created an Image Upload field for a User Photo in the User Profile section in the wp-admin using Advanced Custom Fields. I realized ACF could do this per this post: Photo gallery on profile page?

How would I go about capturing the contents of the image src field in ACF? The following does not work:

<?php $publisher_photo = get_field('user_photo'); ?>

<?php echo "<img class='publisher-picture' src='$publisher_photo' />"; ?>

I even tried this, but it does not work either:

<?php $publisher_photo = get_the_author_meta('user_photo'); ?>
<?php echo "<img class='publisher-picture' src='$publisher_photo' />"; ?>

When I try to debug and echo the contents of the $publisher_photo variable, it comes back blank leading me to believe I'm not picking up this field from the User Profile in the correct way.

share|improve this question
    
In addition, when I do some debugging, such as: <? php echo $publisher_photo; ?> This is not returning anything. The variable appears to be blank. –  Brian Jan 1 '13 at 2:32
    
Thanks for this bit of code. Has worked perfectly... However do you know why it is cropping the image to 150px x 150px? Is it possible to display the original size? Thanks –  William Hibberd Feb 8 at 17:03
add comment

2 Answers

Got it working! Here's what solved my problem:

<?php
$publisher_photo = get_the_author_meta('user_photo');
$image_src = wp_get_attachment_image_src($publisher_photo);
echo '<img class="publisher-picture" src="'. $image_src[0] .'" />';
?>
share|improve this answer
add comment

Because it's not reading your variable $publisher_photo. Try <?php echo '<img class="publisher-picture" src="'. $publisher_photo .'" />'; ?>

share|improve this answer
    
That didn't work for me..Still shows up blank in the view. –  Brian Jan 1 '13 at 2:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.