Skip Navigation

[Resolved] The ID for an image is displaying, not the image

This thread is resolved. Here is a description of the problem and solution.

Problem: I am using a Types shortcode to display an image from a custom field created in Advanced Custom Fields. Instead of the image tag, I am seeing a number.

Solution: Use ACF's shortcodes to access their image fields instead of Types shortcodes.

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by HashimW3633 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#559202
acf.png
instructor bio.png
views image.png

I am trying to: Create a view that displays an image

<wpv-loop>
<h3>[wpv-post-field name="instructor_name"]</h3>
[wpv-post-field name="instructor_photo"]</br>
[wpv-post-field name="instructor_bio"]
</wpv-loop>

I expected to see: The "instructor name", the "instructor photo", and the "instructor bio"

Instead, I got: An image ID instead of the image.

Note: I used Advanced Custom Fields to make the image field.

#559353

Hi, there's not a straightforward way to get an image from ACF fields using Types, because there's not a simple way to get an image field's URL from ACF. ACF stores the attachment ID instead of a URL to the image, so extra custom code to turn the attachment ID into an attachment URL. Here are some references for you:
1) wp_get_attachment_image
Get an HTML img element representing an image attachment
https://developer.wordpress.org/reference/functions/wp_get_attachment_image/

2) add shortcode
Adds a hook for a shortcode tag.
https://codex.wordpress.org/Function_Reference/add_shortcode

Otherwise, it's probably best to consult their support forums to see if there's a simple shortcode you can use to access the field. I'm not the best source of information about their fields, but quick search led me to this forum post:
hidden link

#560378

I'm now using the ACF image shortcode and it works fine. Thank you for going above and beyond, Christian!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.