This guide explains how to change product thumbnail size in emails which are being sent by WooCommerce emails by adding a custom code snippet and ensuring your theme settings support the required image sizes.
How to Change Product Thumbnail Size in MoreConvert Emails #
Add the Custom Code Snippet #
To modify the product image size in WooCommerce emails, add the following code snippet to your theme’s functions.php
file or a custom plugin:
// Resize the image thumbnail @ MoreConvert Email Automations
add_filter( 'wlfmc_email_item_class', 'wlfmc_customize_email_item_thumbnail', 10, 2 );
function wlfmc_customize_email_item_thumbnail( $image, $item ) {
$product = $item->get_product();
if ( is_object( $product ) ) {
$image = $product->get_image( 'woocommerce_thumbnail', array( 'style' => 'max-width:300px !important;height:auto;' ) );
}
return $image;
}
This snippet modifies the image size used in WooCommerce emails. It applies a max-width of 300px to ensure larger display while maintaining responsiveness.
The function hooks into WooCommerce’s email system to replace the default image size.
Ensure Your Theme Supports the Correct Image Size #
The code above relies on the woocommerce_thumbnail
size. If your images are still small, your theme may not support larger sizes.
Checking Available Image Sizes in Your Theme
- Log in to WordPress and go to Settings > Media to review default image sizes.
Snapshot of WordPress Media Settings - Navigate to Appearance > Customize > WooCommerce > Product Images (if your theme supports it).
Snapshot of WooCommerce Product Images Settings - Ensure Thumbnail Width is set to an appropriate value (e.g., 400px or higher).
Regenerate Thumbnails to Apply Changes #
After making these changes, you need to regenerate images so the new size takes effect.
Using the Regenerate Thumbnails Plugins
- Go to Plugins > Add New and search for Regenerate Thumbnails.
- Install and activate the proper plugin.
Test the Email to Verify Changes #
Once you’ve added the code and adjusted the image sizes, send a test email to check if the product images appear at the correct size. If not, try increasing the Thumbnail Width further.