ACF functions for IMG not linking to image
-
Evening,
I’m new to ACF and have started to implement it on my TwentyFifteen child theme which uses a Custom Post Type for a gallery of artwork. The other fields I have tried have worked as expected but I’m having trouble with the most important one for this task – images.
I’ve tried two methods from the documentation.
1. From Displaying Values in your theme
<img src="<?php the_field('art'); ?>"/>
Which displays a broken image symbol and shows this in the source code:
<img src="286, , Prowl into the Spotlight, , , image/jpeg, http://www.pamelaruddy.co.uk/pr_wp/wp-content/uploads/2015/08/IMG_1341.jpg, 1031, 825, Array"/>
Which seems to be an array of all the data to do with the image.And
2. From ‘Code Examples’<?php $artworkimage = wp_get_attachment_image_src(get_field('art'), 'full'); ?> <img src="<?php echo $artworkimage[0]; ?>" alt="<?php echo get_the_title(get_field('artworkimage')) ?>" />
Which just displays an empty SRC with the alt tag:
<img src="" alt="Prowl into the Spotlight" />
The image does display in the admin section when I’ve uploaded it. And the URL displayed within the array does link to the image, so it is there. As the other custom fields from the group do work, I’m sure I’ve added it to the correct template.
Obviously the info is there, I’m just not sure how to pull the right bit into the SRC part of the image tag.
This is the page (custom post type ‘artwork’) I’m experimenting with, I’ve take off the ‘Coming soon’ plugin specially for you so don’t expect it to be pretty or anywhere near finished.
Thanks
- The topic ‘ACF functions for IMG not linking to image’ is closed to new replies.