Online store performance and site speed optimization
Hi Everyone,
Was checking my website SEO, and found that the alt text for my featured collections is missing, even though the images have alt text. How can I adjust the code so that the alt text is available on all pages with the featured collection?
Solved! Go to the solution
This is an accepted solution.
Hii @limelight91 Just add this code in theme.liquid at last.
<script>
setTimeout(() => {
document.querySelectorAll('img').forEach((image, index) => {
if (!image.alt) image.alt = `{{ shop.name }} image--${index}`;
if (index > 2) image.loading = 'lazy';
})
}, 2000);
</script>
Thank You
Regards
Team BoostStar.
Hope it helps. Let us know if you need further help with the issue.
Boost Star || Shopify Expert
This is an accepted solution.
Hii @limelight91 Just add this code in theme.liquid at last.
<script>
setTimeout(() => {
document.querySelectorAll('img').forEach((image, index) => {
if (!image.alt) image.alt = `{{ shop.name }} image--${index}`;
if (index > 2) image.loading = 'lazy';
})
}, 2000);
</script>
Thank You
Regards
Team BoostStar.
Hope it helps. Let us know if you need further help with the issue.
Boost Star || Shopify Expert
@BoostStar
This isn't a real solution as a blind person isn't going to appreciate alt text like the one that would result from that code.
Hi @oreoorbitz ,
if you want to add alt text without using code then you can update the alt text on products.
follow the steps
- go to product
- open media
- and update the alt text from every images
note - if images are not the part of products then you can pass alt attribute in <img> tag.
<img src="" alt="">
Thanks
For future googlers:
In sections/main-collection-banner.liquid around line 37, change the
alt=""
to
alt="{{ collection.image.alt }}"
Thanks. Unfortunately this didn't fix the issue for my shop.
It looks like we have yet another Shopify bug that we will need to fix by inserting custom code, thus preventing us from updating our theme version going forward.
Maybe an enterprising app developer will create an app for this and get a recurring revenue stream as a reward for helping people work around another Shopify bug.
This platform is broken. If any shopify devs are listening, please prioritize bug fixes like this and stop relying on your partners to clean up your mess.
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023