Site logo

Archived topic

ALT tags not appearing on single image featured posts

5 replies · Started by Brett on November 10, 2022

Viewing posts 1–6 of 6

Hello, I am having an issue seeing the ALT tags for the featured image/header image on the pages of single listings on my site. This is a sitewide global issue, as I have added ALT texts to all the featured images. There's something in the code that isn't displaying the ALT text. Would you mind taking a look please?

Hey Fernando, I am using the WP Rocket and Shortpixel plugins for performance, but they shouldn't be altering the images. I tried step 1 as suggested and didn't see any change other than performance declines.

As a note, the site is built on GenteratePress blocks, so it's a fully custom build. I am curious to know if the developer accidentally set things up in the wrong way? It's not a standard build, so I'll rely on you to give it a second look.

Hi there,

plugins that optimize / convert images actually swap out the HTML. In this case they replace the <img> HTML that WP generates for a <picture> element.

If i check the source code of the site i can see that process has occurred.

And in the noscript copy of the image code, which generally keeps most of the original HTML intact, i can see the alt tag.

See here:

https://www.screencast.com/t/5QKDdoRFTfL

So somewhere between the optimization, webp conversion and lazyloading the ALT tag has been misplaced in the outputted picture element.

Got it, thanks. I'll reach out to WP Rocket and Shortpixel to see if it's something that is happening with their plugins. I appreciate the help!

You're welcome

This archived topic is closed to new replies.