Home › Forums › General Issues › Image field as content returns only the url › Reply To: Image field as content returns only the url
If you want to display an image tag you’re best choice is to set the field to return the attachment id, then use that to call one of the WP functions to get the image. The easiest way would probably be http://codex.wordpress.org/Function_Reference/wp_get_attachment_image
$attachment_id = get_field('my_image_field');
if ($attachment_id) {
$size = 'full'; // set to the defined image size you want
$image_tag = wp_get_attachment_image($attachment_id, $size);
if ($image_tag) {
echo $image_tag;
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.