alt, title tags not showing

I have added alt tags, title and description on all the images on my website but none are showing when I check them in the inspect element tool in chrome or firefox.

Here’s a screenshot:

enter image description here

And here’s the screenshot of inspect element of the same image:

enter image description here

4 Answers
4

It actually depends upon how the image is shown in the template. If it is shown using a function like the_post_thumbnail() which returns complete html string to show image with alt then there should be no problem but if image is shown by only fetching URL then it depends how it is displayed .

For example, below is snippet which is fetching image directly on a WP image attachment page:

//fetching attachment image src url 
$attachment_size = apply_filters( 'abc_attachment_size', array( 960, 960 ));
$image_attributes = wp_get_attachment_image_src( $post->ID, $attachment_size); 

if( $image_attributes ) {
?> 
<img src="https://wordpress.stackexchange.com/questions/253743/<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
<?php } ?>

In above code, we are displaying image from data we fetched individually, here since alt is not used , it will not show alt. Similarly in your case, I am assuming its because theme has no alt specified, its not being shown there.

Also, I tried downloading your theme file but was reported as malicious by browser so I left it.

Leave a Comment