BEAR - WooCommerce Bulk Editor and Products Manager Professional

WooCommerce bulk change featured image, gallery and alt text

To bulk change the featured image of WooCommerce products, you set one image ID on many products at once: every product in a category, every product that has no image yet, or the whole shop. In BEAR this is the Thumbnail field of the Bulk Edit tab, and it works on all filtered products, not only on the page you see. Below is how to do it, how to remove main images and edit galleries in bulk, and what to do about image files and alt text, which belong to the media library rather than to the products.

Where WooCommerce keeps product images

A product does not contain images; it points to them.

  • The featured image (WooCommerce calls it Product image) is one attachment ID stored in the product's _thumbnail_id meta. In BEAR it is the Thumbnail column, on by default.
  • The gallery (Product gallery) is a list of attachment IDs in _product_image_gallery. In BEAR it is the Gallery column, which you switch on in the Settings tab.
  • The image itself is an attachment in the media library: the file, its resized copies, its title and its alt text.

So changing or removing an image on a product only changes the ID the product points to. The file stays where it is, one image can serve a thousand products, and its alt text is the same on all of them. Thumbnail and gallery are also separate fields: changing the gallery does not change the main image, and the other way round.

Bulk change the featured image of filtered products

  1. In the Filters tab, select the products: a category, a product type, a stock status or any other condition, then press Filter. If you set no filter and tick no products, the next step changes every product in the shop, and the confirmation message warns you about it.
  2. Open the Bulk Edit tab and its Additional section.
  3. Tick Thumbnail, press select thumbnail and choose the image in the media window, or upload a new one there.
  4. Press Do Bulk Edit and wait for the progress bar to reach 100%.

The table shows one page of rows at a time (Default products count per page in the Settings tab), but the bulk run is not limited by that: it processes every filtered product in batches, so 40,000 products need one run, not 400 selections. For very large runs see bulk editing thousands of products. Each change is written to History, so a wrong image can be reverted.

When each product needs its own photo, click the image in its Thumbnail cell and choose the right one. Products without an image show a placeholder picture in that cell; it is clickable like any other. To give a handful of ticked products the same image, switch on binded editing and change the image of one of them. With the variations switch off, all of this changes parent products only; variation images are covered in bulk editing variation images.

Only products that have no image yet

Set the Thumbnail filter to Empty, press Filter, and run the steps above. Empty means the product has no _thumbnail_id record at all. A product whose image was removed in bulk (next section) keeps the record with the value 0, so this filter does not list it; such products appear under Not empty with a placeholder in the Thumbnail column. Finding products without a category or image shows the other "what is missing" filters.

The same image for every product in a category

Filter by the category and run the bulk edit. All products then point to one attachment: no extra files are created, and they share its alt text.

If what you really want is a default picture for products that have no photo, for example in a feed that adds products every day, the bulk edit is the wrong tool: it only reaches products that exist now, and every one of them must be changed again when its real photo arrives. WooCommerce has a setting for this, Placeholder image under WooCommerce → Settings → Products. It is shown for every product without an image, including products added later, and writes nothing to the products.

Remove the featured image in bulk

  1. Filter the products whose main image should go.
  2. In the Additional section of the Bulk Edit tab, tick Thumbnail and do not select any image.
  3. Press Do Bulk Edit.

The image ID of these products is set to 0, and the shop shows the WooCommerce placeholder for them. The files stay in the media library, and the run can be reverted in History.

Edit, reorder and clean product galleries

Switch on the Gallery column in the Settings tab and save. Each cell then shows the first images and their count; a click opens the gallery of that product.

  • Add: Add Image opens the media window; new images are placed at the start of the list.
  • Remove: the trash icon on an image takes it out of the gallery.
  • Reorder: drag the images. The order in the window is the order on the product page.
  • Press Apply to save.

Reordering is per product, because every product has its own images. Binded editing copies the whole gallery of the edited product to all ticked products, so use it only when they should end up with identical galleries.

For many products at once, tick Gallery in the Additional section of the Bulk Edit tab, press its Images button, add the images and choose what to do with them:

OperationResult for each filtered product
Replace all products images by the selected onesThe gallery becomes exactly the selected images. With no images selected, the galleries are emptied.
Add selected images to the already existed onesThe selected images are added after the existing ones.
Delete selected images from the productsThe selected images are taken out of the galleries; the files stay.
Delete selected images from the products, also delete them from the media library foreverAs above, and the selected files are deleted from the site.

Press Apply in the window, then Do Bulk Edit. Step-by-step examples: adding two images to every gallery and removing images from the galleries of some products. In the free version the gallery is edited in its cell only; the Bulk Edit tab and binded editing do not change it (see free version limitations).

Delete product images from the media library

Removing an image from a product never deletes the file: not when you set the Thumbnail to nothing, not when you empty a gallery, and not when you delete the product. This is deliberate, because the same file may be used elsewhere. Disk space is only freed when the attachment itself is deleted.

The one exception is the last gallery operation in the table above. It deletes the attachments you selected in the window, with all their resized copies, and it is meant for a known set of images, for example an old banner that was added to every gallery. Before you use it:

  • It deletes only the images you selected, not every image of the filtered products. Main images are not included unless you select them.
  • The deletion is site-wide. A deleted image disappears from every product that used it, including products outside the filter and products that had it as their main image.
  • It cannot be undone. History can put the IDs back into the galleries, but the files are gone. Make a backup of the uploads folder first.

To clear the photos of old products and keep their texts, remove the images from the products in BEAR, then delete the files in Media → Library. WordPress has no built-in check for unused images. The Unattached filter in the media library is not one: an image chosen from the library for a product's Thumbnail or gallery is not attached to that product (only an image uploaded from a Thumbnail cell is), so an unattached image can still be in use. Look at the image in the media library before deleting it, or use a dedicated media cleanup tool and review its list.

Alt text belongs to the image, not to the product

The alt text is stored with the attachment, in its _wp_attachment_image_alt meta, and WooCommerce prints it wherever the image is shown. BEAR edits products, so it has no alt text column. Adding _wp_attachment_image_alt in the Meta Fields tab does not help either: that tab edits product meta, so the value is saved on the products and the images do not change. And since one image has one alt text, a picture shared by many products cannot have a different alt on each of them.

For a few images, edit the alt text while you pick them: the media window opened by the Thumbnail cell or Add Image shows the image details on the right, and the Alternative Text field there is saved directly to the image. Media → Library has the same field.

To fill empty alt texts of all product images with the product name, run a short script once with WP-CLI. It leaves existing alt texts alone; an image shared by several products gets the name of the first one.

<?php
/*
 * Fill EMPTY alt texts of product images (main image + gallery) with the product name.
 * Save as fill-product-image-alt.php, run once from the WordPress folder:
 *     wp eval-file fill-product-image-alt.php
 * then delete the file.
 */
$product_ids = wc_get_products( array(
    'status' => array( 'publish', 'draft', 'pending', 'private' ),
    'limit'  => -1,
    'return' => 'ids',
) );

foreach ( $product_ids as $product_id ) {
    $product = wc_get_product( $product_id );
    if ( $product instanceof WC_Product ) {
        $image_ids = array_merge( array( $product->get_image_id() ), $product->get_gallery_image_ids() );

        foreach ( array_filter( array_map( 'absint', $image_ids ) ) as $attachment_id ) {
            $alt = (string) get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
            if ( '' === trim( $alt ) ) {
                update_post_meta( $attachment_id, '_wp_attachment_image_alt', sanitize_text_field( $product->get_name() ) );
            }
        }
    }
}

PDFs and custom image lists in meta fields

The Meta Fields tab offers a gallery view for a meta key. It is not a general file list: the media window it opens shows images only, and other files are hidden in the cell. In 2.2.4 it also has a display problem: the cell of a gallery meta field shows the product's WooCommerce gallery instead of the content of its own key. What you save there is written to the key but does not appear when you open the cell again, and pressing Apply copies the WooCommerce gallery into the key. Do not use it for extra galleries or attachments for now.

To attach PDFs or a second image list to products, store the attachment IDs as text, for example 123,456, in a meta field with the textinput view, and let your theme code read the key. The text value can be set for many products at once like any other field; the meta fields documentation explains how to add the key.

If the images do not change

  • The Gallery field is missing in the Bulk Edit tab. Switch on the Gallery column in the Settings tab first; the bulk field only appears for an active column.
  • A shop manager does not see Thumbnail or Gallery. The fields can be hidden per role; see shop manager permissions.
  • The editor shows the new image, the shop the old one. Clear the page cache and the CDN cache. If the product page still shows the old picture, the theme may be showing a variation image or a gallery from another plugin.
  • Only the first page changed. You edited cells or used binded editing on ticked rows. For all filtered products, use the Bulk Edit tab and leave products unticked.

If the images still do not behave as described, open a topic on the BEAR support forum with the steps you took and the plugin and WooCommerce versions.