Dear Peer,
I've checked and this is not currently possible with types_render_field. But there is a workaround. You can retrieve the Types image field using WordPress get_post_meta and then display also its image description. Try this in your test site:
Step1.) Add this code to your theme functions.php:
function pippin_get_image_id($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url )); return $attachment[0]; }
This code is explained here: https://pippinsplugins.com/retrieve-attachment-id-from-image-url/
It will retrieve the attachment ID based on image URL.
Step2.) In the template where you are using the types_render_field previously, remove that and replace it with the code below:
<?php global $post; if (isset($post->ID)) { $post_id=$post->ID; //Get images $images=get_post_meta($post_id,'wpcf-artist-media1-images'); //Loop through the images and get the attachment ID, used in getting image description if ((is_array($images)) && (!(empty($images)))) { foreach ($images as $key=>$image_url) { //Retrieve post ID of this attachment image $post_id_attachment=pippin_get_image_id($image_url); if (isset($post_id_attachment)) { //Get description of this image as defined in WordPress media library $image_post_object = get_post($post_id_attachment); $image_description = $image_post_object->post_content; //Output the image URL and its description echo '<br />'; echo "Image URL: $image_url<br />"; echo "Image description:$image_description<br />"; echo "<br /><br />" ; } } } } ?>
NOTE: To retrieve Types custom field values using get_post_meta you need to append it with wpcf- prefix. So if your custom field slug is artist-media1-images, it will become wpcf-artist-media1-images.
See the output in the browser. You can see the output of the image URL and its corresponding image description as saved in Media Library (see screenshot example). You can then easily modify the above code to use them in hyperlinks.
Please let me know how it goes. Thanks
Cheers,
Emerson