Product Widget Image Doesn't Have Alt Tag

Title it’s self explanatory. It’s not possible to add the description nor the alt tag to the images in the product widget. Will this be ever solved in the next Ghost updates?

1 Like

Any news about this?

Hi @block, thanks for the post - I’ve added this request to our backlog. Right now we’re prioritizing work on the beta editor so I do not have a timeline I can give you for this.

Till the time this feature ships, you can add the below code in your “Site Footer” using “Code Injection” in Ghost settings.

    const divs = document.querySelectorAll('.kg-product-card-container');
    for (const div of divs) {
      const images = div.querySelectorAll('img');
      const titles = div.querySelectorAll('h4');
      for (var i = 0; i < images.length; i++) {
        images[i].alt = titles[i].textContent;

This seems to do the trick in a simple way. Please note that this can be further optimized but why over engineer when the feature will roll out soon.

This code assumes that all Product cards have an image and a title.

Thank you both! I will wait for the official release and try also this temporary solution. The errors on Semrush started to increase and I got worried :slight_smile:

Please note that Semrush might not detect these new changes. Since these are done via JavaScript, you need to have Guru or Business plan on Semrush to enable JavaScript during your campaign runs in Semrush.
In short, this will not remove errors from Semrush despite adding alt attributes to all Product images.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.