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

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.

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 topic contains 2 replies, has 2 voices, and was last updated by  HashimW3633 4 months ago. The support staff assigned to this topic is Christian Cox.

Viewing 3 posts - 1 through 3 (of 3 total)
Author
Posts
#559202

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

Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-05:00)

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!

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