I am trying to: display alt and title tag for a image field (repeating image field. not a group, just image)
Instead, I got: No alt and title.
Here's the code i used in views:
[wpv-for-each field="wpcf-imagens-galeria"]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
<a rel="lightbox" href="[types field='imagens-galeria' output='raw'][/types]" class="lightbox">
[types field='imagens-galeria' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types]
</a>
</div>
[/wpv-for-each]
I've tested workarounds and nothing. Searched the forum and most of the answers don't work.
If i set:
Then it works, all the images are showing blablabla as title. So variable %%TITLE%% and %%ALT%% are not working. I want to show title of image the same as defined in the multimedia area of WordPress. How can i achieve this?
I've tested:
[types field='imagens-galeria' title='%%TITLE%%' alt='[my-images]' size='full'][/types]
And functions.php:
add_shortcode('my-images', 'my_images_shortcode');
function my_images_shortcode() {
global $post, $wpdb;
$images = get_post_meta($post->ID, 'wpcf-imagens-galeria', false);
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 = '$alt';
}
return $out;
}
But this does not return any image, it appears all blank.
Hello,
I assume we are talking about a multiple instances image field "imagens-galeria", I have tried the same shortcodes you mentioned above in my localhost with a fresh wordpress installation + the latest version of Toolset plugins:
[wpv-for-each field="wpcf-imagens-galeria"]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
<a rel="lightbox" href="[types field='imagens-galeria' output='raw'][/types]" class="lightbox">
[types field='imagens-galeria' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types]
</a>
</div>
[/wpv-for-each]
It works fine, I can see the image title and alt in the HTML codes, see screenshot: image2.JPG
Please check these in your website:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again
2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/
3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/
Thanks for the details, I am downloading the files, will update here if there is anything found
I can see the same problem in my localhost with your database dump file.
Here are what I found:
1) Edit the post "Galeria 3D print":
hidden link
2) Add an item in image field "Imagens", setup the new image item title and alt values, see screenshot: image4.JPG
3) Test it in front-end, I can see both title and alt tags work fine, see screenshot image5.JPG
I suggest you edit the post "Galeria 3D print", setup alt and title tags for each item of image field "Imagens", and test again.