From b2fd0330a82b15fe50e12166269115ea24d95231 Mon Sep 17 00:00:00 2001 From: Twooey Date: Thu, 27 Aug 2026 17:00:39 -0400 Subject: [PATCH] Fix book covers being cropped to squares in the shop grid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported: cover images looked cropped top/bottom. Confirmed directly — WooCommerce's woocommerce_thumbnail size defaults to a hard 1:1 crop (unset woocommerce_thumbnail_cropping option defaults to '1:1' in WC core), so a 335x500 portrait cover was being force-cropped to 300x300 for the shop grid, cutting off the top and bottom of every cover. woocommerce_thumbnail_cropping is a real, admin-configurable WooCommerce setting (WooCommerce > Settings > Products > Display in wp-admin) — not a WooCommerce code change. Set to 'uncropped', which makes the thumbnail proportional instead (verified: same cover now generates a 300x448 woocommerce_thumbnail, matching its actual aspect ratio). wc_get_image_size() caches the computed size in the object cache, so also flush the cache right after — confirmed the option update alone did NOT take effect until flushed (Redis was serving the stale pre-change size definition). Added to deploy.sh alongside the other WooCommerce option settings it already manages (HPOS, blog_public) so every environment gets this by default rather than needing the same manual fix on each one. Verified via a real dev deploy run (idempotent, no errors) and by regenerating the already-synced covers' thumbnails and confirming their new dimensions. --- deploy/deploy.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 9cfa350..975d14d 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -112,6 +112,16 @@ echo "==> enabling WooCommerce HPOS (custom order tables)" $WP option update woocommerce_custom_orders_table_enabled yes $WP option update woocommerce_custom_orders_table_data_sync_enabled yes +# WooCommerce's default (unset -> '1:1') force-crops every product +# thumbnail to a square — confirmed directly: a 335x500 portrait book cover +# was landing at a hard-cropped 300x300 shop-grid thumbnail, cutting off +# the top and bottom of the cover. 'uncropped' makes it a proportional +# 300x448 instead. wc_get_image_size() caches the computed size in the +# object cache, so the option change alone doesn't take effect until flushed. +echo "==> uncropped product thumbnails (book covers are portrait, not square)" +$WP option update woocommerce_thumbnail_cropping uncropped +$WP cache flush + if [[ "$ENVIRONMENT" != "production" ]]; then echo "==> discouraging search engines (non-production)" $WP option update blog_public 0