After countless unsuccessful attempts yesterday, I even dreamed very ambiguously about it, but I managed in the morning to solve and put an alt text for the thumbnail.
WARNING:Use a test site for your theme if you do this.
https://my.wealthyaffiliate.com/training/using-mal...
Go to Appearance, Editor, Choose Header.php and add the code
<?php
$img_id = get_post_thumbnail_id($post->ID); // This gets just the ID of the img
$image = wp_get_attachment_image_src($img_id, $optional_size); // Get URL of the image, and size can be set here too (same as with get_the_post_thumbnail, I think)
$alt_text = get_post_meta($img_id , '_wp_attachment_image_alt', true);
$perm = get_permalink($post->ID);
?>
<a href="<?php echo($perm); ?>" title="<?php the_title(); ?>"><img src="<?php echo($image[0]); ?>" width="<?php echo($image[1]); ?>" height="<?php echo($image[2]); ?>" class="alignleft" alt="<?php echo $alt_text; ?>" /></a>
I put it in my Header.php after :
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
$url = $thumb['0'];
?>
Now, I test it again with https://varvy.com/
Victory!
All my features images from my Homepage have an alt text!
See my other training here
https://my.wealthyaffiliate.com/dorina62/training: