Skip to content

Black Friday 50% off your first year on all premium plugins and the Suite.

See the deals

Product names as alt text

Fill empty WooCommerce product image alt text with the product name — free, without AI, and without retyping every image.

3 min read · Updated 6 November 2026

A typical shop has hundreds of product photos with no alt text, because nobody types it in while adding products. The product name is usually a decent description of the main photo. Here is how to put it to work, from a quick code snippet to a plugin that writes it into the Media Library for you.

What WooCommerce does on its own

WooCommerce prints product images with the alt text stored in the Media Library. If that is empty, recent WooCommerce versions (9.3 and later) fall back to the product name on the single product gallery — “Blue Linen Tote Bag”, then “Blue Linen Tote Bag - Image 2” and so on. That fallback only applies in the product gallery. Shop and category grids, related products, theme or builder templates and anything reading the Media Library (feeds, sitemaps, other plugins) still see an empty field.

Option 1: a code snippet that fills alt text at display time

Add this to a code snippets plugin or your child theme’s functions.php. When an image attached to a product has no alt text, the product name is used on output. Nothing is saved to the database.

add_filter( 'wp_get_attachment_image_attributes', function ( $attr, $attachment ) {
	if ( ! empty( $attr['alt'] ) ) {
		return $attr;
	}
	$parent = get_post( $attachment->post_parent );
	if ( $parent && 'product' === $parent->post_type ) {
		$attr['alt'] = wp_strip_all_tags( get_the_title( $parent ) );
	}
	return $attr;
}, 10, 2 );

Limits: it only works where images are printed with WordPress’s image functions, every photo of a product gets the same text, and the Media Library itself stays empty.

Option 2: write it with ByteKeel PixTag

ByteKeel PixTag is free and runs on your server. It saves real alt text in the library, so every template, feed and plugin sees it.

  1. Install ByteKeel PixTag and open ByteKeel PixTag › Settings.
  2. Set Generation Method to Context-aware.
  3. Set Template to %posttitle% %filename% — the product name followed by the cleaned file name, so “Blue Linen Tote Bag Side View” for side-view.jpg. Use %posttitle% alone if your file names are camera numbers.
  4. Save. Generate alt text for new product photos from the Media Library or the Bulk Processor (ByteKeel PixTag Pro does it automatically on upload).
  5. For photos already in the shop, open Media › Library in list view, select the images and run the Generate Alt Text bulk action. Images that already have alt text are skipped.

The one thing to know: “attached” images

%posttitle% is the title of the post an image is attached to. Photos you upload through Set product image or Add product gallery images on the product’s edit screen are attached to that product. Photos uploaded somewhere else first and then picked from the library are not — for those ByteKeel PixTag falls back to the file name. In Media › Library list view, the Uploaded to column shows which product an image belongs to.

Make it better than just the name

  • Name files by view or variation before uploading: front.jpg, side-view.jpg, in-use-on-shoulder.jpg. With the template above every image gets a distinct description.
  • Write the main image’s alt text by hand for your best sellers. ByteKeel PixTag will not overwrite it.
  • Leave out prices, “buy now” and keyword lists. Alt text describes the picture.

If your photos are named IMG_1234.jpg and the product name is not enough, ByteKeel PixTag Pro can describe each photo with OpenAI or Claude instead.

With ByteKeel PixTag Pro, new product images get alt text the moment you upload them: see Automatically generate alt text in WordPress. For photos whose file names say nothing useful, compare filename-based alt text with AI vision.

Frequently asked questions

Is using the product name as alt text good for SEO?

It is far better than empty alt text and matches what shoppers search for. For the main image of important products, a sentence that also says what is shown (colour, angle, setting) is better still.

Is it a problem if several images have the same alt text?

It is not an error, but it tells a screen-reader user nothing new on image two and three. Adding the view or variation, as above, fixes that.

Does this work for variation images?

Variation images uploaded from the product edit screen are attached to the parent product, so they get the product name. Add the variation (colour, size) to the file name to tell them apart.

Will it change alt text I already wrote?

No. The bulk action and the Bulk Processor’s default scope skip images that already have alt text, and so does ByteKeel PixTag Pro’s upload trigger.

Did this answer the question? No — open a support request