[Closed] Image Field Type / Featured Image : How can I display image title / alt / desc?

Hi, we have a longer queue than usual at the moment, the wait time is around 20 hours, please hold on while we reply to tickets in the order they are opened.

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 topic contains 3 replies, has 2 voices.

Last updated by Caridad 5 years, 8 months ago.

Assigned support staff: Caridad.

Author
Posts
#99750

Hi!

I am have a custom type that uses both a featured image and multiple image field types. For these images i need to display the image title and description (as entered into wp via the media library). How do i go about doing this? Thanks!!

#100218

Dear Sammut,

We have a request in our system for this, but for now you will have to use some custom shortcodes. There are some examples here:

https://toolset.com/forums/topic/add-featured-image-url-alt-text-and-description-shortcodes/

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#100282

OK, yes, I see. So say I have set a custom type that is using the image repeater field; how can doa repeater fiels that would ask for image name, desc and image upload. My goal is to have multiple images attached to my custom post type.

#100666

Dear Sammut,

I have written some code that displays the images from a repeating field called 'images' and also adds the alternative text to it. You can adjust this to your needs and use [my-images] in the Content Template to display it.

add_shortcode('my-images', 'my_images_shortcode');
function my_images_shortcode() {
global $post, $wpdb;

$images = get_post_meta($post->ID, 'wpcf-images', false);
$out = '<ul>';
foreach ($images as $image) {
$attachment_id = $wpdb->get_var($wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid = %s",
$image
));
$alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
$out .= '<li><img src="' . $image . '" alt="' . $alt . '" title="' . $alt . '" /></li>';
}
$out .= '</ul>';
return $out;
}

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

The topic ‘[Closed] Image Field Type / Featured Image : How can I display image title / alt / desc?’ is closed to new replies.