WC Real ALT
Show real ALT's from media library for woocommerce images
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/neevalex/wc-real-alt/archive/refs/heads/main.zipUse the real ALT text from the Media Library for WooCommerce product images, instead of WooCommerce's generated "product name + SKU" text.
Contributors: neevalex Requires at least: WordPress 6.0, WooCommerce 6.0 Requires PHP: 7.4 License: GPLv2 or later
Description
By default, WooCommerce generates ALT text for product images on the fly (typically something like Product Name SKU) whenever an image doesn't already have its own ALT text. That's a useful fallback, but it also means real ALT text you've carefully written for an image in the Media Library can end up being ignored in favor of the generated text.
WC Real ALT makes sure the real Media Library ALT text always wins when it's actually set on the image:
- If the product image has ALT text set in the Media Library, that text is used everywhere: single product page, product gallery, shop/archive pages, category pages, related products, etc.
- If the image has no ALT text set in the Media Library, WooCommerce's normal generated ALT text (product name, SKU, etc.) is used as a fallback — nothing changes for images without their own ALT text.
The plugin only affects WooCommerce product images. It does not touch ALT text for unrelated images elsewhere on the site.
No settings, no configuration — install and activate.
Installation
- Copy
wc-real-alt.phpinto awc-real-altfolder under/wp-content/plugins/(or zip this repo and upload it via Plugins → Add New → Upload Plugin). - Activate the plugin through the Plugins menu in WordPress.
- Make sure WooCommerce is installed and active.
- Set real ALT text on your product images in the Media Library (edit the image, fill in the "Alternative Text" field) — it will now be used automatically.
How it works
The plugin hooks the relevant WordPress/WooCommerce filters at the latest possible priority:
wc_get_product_attachment_propsandwoocommerce_gallery_image_html_attachment_image_params— cover the single product page gallery image.wp_get_attachment_image_attributesandwoocommerce_product_get_image— cover archive/shop/category loops and related products.
All of them prefer the image's real _wp_attachment_image_alt Media Library value when it's set, and leave WooCommerce's generated fallback untouched otherwise.
Some themes rebuild product image markup themselves and re-inject generated ALT text after WooCommerce's own filters have already run, bypassing all of the above. As a safety net, the plugin also buffers the final rendered HTML on single product, shop, and product archive/category/tag pages and patches the alt/title attribute of any <img> tag whose src resolves to an attachment with real ALT text set — this runs after everything else, theme included, so it applies no matter how the image markup was generated. It never touches images that don't have real ALT text set, and it's scoped to WooCommerce product pages only.
FAQ
Does this change anything for images that don't have ALT text set? No. If an image has no ALT text in the Media Library, WooCommerce's default generated ALT text is still used, exactly as before.
Does this affect images outside of WooCommerce products? No. Only product-related images (single product gallery, product thumbnails on archive/shop/category pages, related products) are affected.
Do I need to configure anything? No settings. Just activate the plugin and set ALT text on your product images where you want it used.
Changelog
1.0.0
- Initial release.