Make WooCommerce product images square for Google Shopping

Published Updated 2 min read

Google Shopping wants product images of at least 500x500 pixels, and it checks both dimensions. A landscape photo at 1200 by 400 fails on height even though it is plenty wide, and Merchant Center holds the listing back until the image is fixed.

The manual fix is to open each image in an editor, pad the short side until the canvas is square, and re-upload. That is fine once. On a store that shoots products in batches, or that inherited its images from another platform, it becomes a recurring chore that gets skipped.

A small plugin automates the padding. It finds product thumbnails that are not square and centres each one on a square white canvas. Nothing is stretched or cropped, so the product looks the same and the image passes.

Why Google Shopping rejects wide product images

Merchant Center applies the 500 pixel minimum to width and height separately, so an image 1200 pixels wide and 400 tall fails the height check however large it looks.

WordPress and WooCommerce leave the source file alone at upload. They generate the thumbnail sizes your theme registers, but the original stays as uploaded, and a 1200x400 JPEG is what goes into the feed.

The usual failures are flat-lays and banner-style shots, images exported from design tools at banner sizes, and product photos migrated from a platform with a different aspect ratio. Once they are in the media library, nothing built in fixes them in bulk.

Scan first, then pad

WooCommerce > Square Images has two buttons. The scan goes through every published product, reads the main thumbnail's dimensions and lists which are square and which are not. It changes nothing.

The pad step takes each non-square thumbnail, makes a white square canvas the size of its longer side using PHP GD, places the original in the centre and saves the result to the same file path, updating the attachment metadata so WordPress knows the new dimensions.

That overwrite has no undo. Back up your uploads directory, or run it on a staging copy first; restoring from backup is the only way back.

Main thumbnails only, white only, no upscaling

Only the image set in the product editor's Set product image panel is processed. Gallery images and images on individual variations are stored differently and are left alone, so if they fail in Merchant Center too, they need a separate pass.

The padding is always white. On products shot against a coloured or textured background, or on transparent PNGs, the added space shows as a white block. Pad those by hand in an editor that lets you choose the fill.

Nothing is enlarged. A square image smaller than 500x500 stays that size, and an image uploaded very small needs a higher-resolution original.

Regenerate, then resubmit the feed

The source file is now right, but WordPress keeps its registered image sizes separately, so the shop grid, category pages and product pages still use the old crops until you regenerate them. Run the free Regenerate Thumbnails plugin, or wp media regenerate --all with WP-CLI.

Then re-fetch or resubmit your Merchant Center feed. Affected items should move from disapproved to active within 24 to 72 hours as Google re-crawls the images.

It is an on-demand tool, not an upload filter. New products with landscape images need another scan and pad. A follow-up message can hook wp_handle_upload or add_attachment so images are checked and padded as they arrive.

What you get

Included

  • Scan all published WooCommerce product thumbnails for non-square dimensions
  • White padding to center non-square images on a square canvas using PHP GD
  • Saves padded images to the same file path, updates WordPress attachment metadata
  • Admin page at WooCommerce > Square Images with scan and pad operations
  • Batch processing of all non-square product thumbnails in one click

Not included

  • Gallery images on product pages, only main product thumbnails
  • Custom padding color, only white
  • Images smaller than 500x500 that are already square, no upscaling
  • Automatic padding on upload, this is an on-demand admin tool
  • Variable product images set on individual variations

Build it in Steem

The button opens the builder with this guide's prompt filled in, so you can change anything before it runs. Nothing is built, and nothing is charged, until you send it.

Build this pluginAbout 55 credits. The free plan includes enough for one.
Read the prompt (337 words)

Build a WordPress plugin called WooCommerce Square Product Images. Plugin Name: WooCommerce Square Product Images. Description: Pads non-square WooCommerce product thumbnail images with white space to meet Google Shopping's 500x500 minimum image requirement. Single PHP file. Requires WooCommerce. Add an admin page under the WooCommerce menu using add_submenu_page, parent slug 'woocommerce'. Page title: Square Product Images. Menu title: Square Images. Capability: manage_woocommerce. Slug: wc-square-images. On the page, render two buttons. Both submit GET requests to the same page. Button 1: Scan Products (GET ?run=scan). Only execute when run=scan and current_user_can('manage_woocommerce') is true. Query all published products with WP_Query(array('post_type'=>'product','posts_per_page'=>-1,'post_status'=>'publish')). For each product, call get_post_thumbnail_id() and get_attached_file(). Skip products with no thumbnail. Call getimagesize() to get width and height. Render a table with columns: Product (linked to the edit post screen in wp-admin), Size, Square. In the Square column, output 'Yes' in green (#006600) or 'No' in red (#cc0000). Button 2: Pad Non-Square Images (GET ?run=pad). Only execute when run=pad and current_user_can('manage_woocommerce') is true. Iterate the same product list. For each product with a non-square thumbnail: get the mime type from the getimagesize() result. Load with imagecreatefromjpeg(), imagecreatefrompng(), or imagecreatefromgif() based on mime type. Let $canvas = max($width, $height). Create a new canvas with imagecreatetruecolor($canvas, $canvas). Fill it white using imagefill() with imagecolorallocate($img, 255, 255, 255). Copy the original centered onto the canvas using imagecopy(), with x-offset ($canvas - $width) / 2 and y-offset ($canvas - $height) / 2. Save back to the same file path: imagejpeg() at quality 90 for JPEG, imagepng() for PNG, imagegif() for GIF. Call wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file_path)) to update the attachment record. Render a result table with columns: Product, Original Size, New Size, Status (Padded / Already Square / Skipped). Apply wp-list-table widefat fixed striped to both tables. Above the results, show a WordPress admin notice with class notice notice-info: 'This tool pads main product thumbnail images only. After padding, run Regenerate Thumbnails or wp media regenerate --all to rebuild your theme image sizes from the updated source files.' No external CSS or JavaScript.