WooCommerce product images can take up a lot of space on your server. One solution would be to host the images on an external cloud and have them used in the templates for the single product page and the product list. Below is a possible solution to do this.

functions.php

/**
 * Use as product image url the value of a custom meta field
 * NOTE: to be used with the custom theme templates
 * <your_tema>/woocommerce/single-produict/product-image.php
 * <your_tema>/woocommerce/single-produict/product-thumbnails.php
 */
function custom_woocommerce_thumbnail() {
	global $product;

	$id = get_the_ID();
	$title = get_the_title();
	$size = 'shop_catalog';

	$post_thumbnail = get_the_post_thumbnail( $id , $size );

	if ($post_thumbnail === '') {
		echo "<div class='thumbnail_container'>";

		//$main_image = get_post_meta($id, 'main_image', true);
		$main_thumb = get_post_meta($id, 'main_thumb', true);

		if ($main_thumb === '') {
			$post_thumbnail = '<img width="450" height="450" alt="' . $title . '" class="attachment-shop_catalog wp-post-image" src="' . wc_placeholder_img_src() . '">';

		} else {
			$post_thumbnail = '<img width="450" height="450" alt="' . $title . '" class="attachment-shop_catalog wp-post-image" src="' . $main_thumb . '">';
		}
		echo $post_thumbnail;
		echo "</div>";
	}
}
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_woocommerce_thumbnail', 10);

/**
 * Add the column for the product image and remove the default column from products list
 */
function custom_admin_products_image_column( $columns ){
	//unset( $columns['thumb'] );

	$ordered_columns = array();
	foreach ($columns as $key => $column) {
		$ordered_columns[$key] = $column;
		if ($key == 'thumb') {
			$ordered_columns['custom-image'] = 'Image';
		}
	}
	return $ordered_columns;
}
add_filter( 'manage_edit-product_columns', 'custom_admin_products_image_column' );

function boralevi_admin_products_image_column_content( $column, $product_id ){
	if ( $column == 'custom-image' ) {
		//$product = wc_get_product( $product_id );
		$main_thumb = get_post_meta($product_id, 'main_thumb', true);

		if ($main_thumb == '') {
			$main_thumb = wc_placeholder_img_src();
		} 
		echo '<img src="' . $main_thumb . '" class="woocommerce-placeholder wp-post-image" alt="Placeholder" loading="lazy" width="80" height="80">';
	}
}
add_action( 'manage_product_posts_custom_column', 'custom_admin_products_image_column_content', 10, 2 );

<your_theme>/woocommerce/single-product/product-image.php

&lt;?php
/**
 * Single Product Image
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-image.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.5.1
 */

defined( 'ABSPATH' ) || exit;

require_once 'Mobile_Detect.php';

// Note: `wc_get_gallery_image_html` was added in WC 3.3.2 and did not exist prior. This check protects against theme overrides being used on older versions of WC.
if ( ! function_exists( 'wc_get_gallery_image_html' ) ) {
	return;
}

global $product;

$product_id    = $product->get_id();
$product_title = $product->get_title();

$main_image = get_post_meta($product_id, 'main_image', true);
$main_thumb = get_post_meta($product_id, 'main_thumb', true);

$html = '';

$columns           = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
$post_thumbnail_id = $product->get_image_id();
$wrapper_classes   = apply_filters(
	'woocommerce_single_product_image_gallery_classes',
	array(
		'woocommerce-product-gallery',
		'woocommerce-product-gallery--' . ( $product->get_image_id() ? 'with-images' : 'without-images' ),
		'woocommerce-product-gallery--columns-' . absint( $columns ),
		'images',
	)
);
?>
&lt;div class="&lt;?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="&lt;?php echo esc_attr( $columns ); ?>" style="opacity: 0; transition: opacity .25s ease-in-out;">
	&lt;figure class="woocommerce-product-gallery__wrapper">
		&lt;?php
		if ($main_image != '') {

			$detect = new Mobile_Detect;

			if ($detect->isMobile()) {
				echo sprintf('&lt;img style="padding: 0;" src="%s" class="woocommerce-main-image" title="%s">', $main_thumb, $product_title);
			} else {
				echo sprintf('&lt;img style="padding: 0;" id="elevatezoom-target" src="%s" data-zoom-image="%s" class="woocommerce-main-image" title="%s">', $main_thumb, $main_image, $product_title);

				echo '&lt;p class="spiegazione-zoom">' . __('Use the mouse to view carpet details.', 'boralevi') . '&lt;/p>';
				echo '&lt;p class="spiegazione-zoom">' . __('Use the mouse wheel to zoom the detail.', 'boralevi') . '&lt;/p>';
			}
			//echo sprintf( '&lt;a href="%s" title="%s" data-rel="prettyPhoto">%s&lt;/a>', $main_image, $product_title, __('Click here to view full image', 'boralevi'));

		} else{
			if ( $product->get_image_id() ) {
				$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
			} else {
				$html  = '&lt;div class="woocommerce-product-gallery__image--placeholder">';
				$html .= sprintf( '&lt;img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
				$html .= '&lt;/div>';
			}
			echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
		}

		do_action( 'woocommerce_product_thumbnails' );
		?>
	&lt;/figure>
&lt;/div>

<your_theme>/woocommerce/single-product/product-thumbnails.php

&lt;?php
/**
 * Single Product Thumbnails
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-thumbnails.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @package     WooCommerce/Templates
 * @version     3.5.1
 */

defined( 'ABSPATH' ) || exit;

global $product;

$temp_gallery_images = get_post_meta($product->get_id(), 'gallery_images', true);
$temp_gallery_thumbs = get_post_meta($product->get_id(), 'gallery_thumbs', true);

if ($temp_gallery_images != '') {
	$gallery_images = explode(',', $temp_gallery_images);
} else {
	$gallery_images = array();
}
if ($temp_gallery_thumbs != '') {
	$gallery_thumbs = explode(',', $temp_gallery_thumbs);
} else {
	$gallery_thumbs = array();
}

echo '&lt;div class="thumbnails">';

$main_image = get_post_meta($product->get_id(), 'main_image', true);
$main_thumb = get_post_meta($product->get_id(), 'main_thumb', true);

if ($main_image != "") {
	echo template_to_html( $main_image, $main_thumb, $product->get_title());
} 

for ($i = 0; $i &lt; count($gallery_images); $i++) {
	echo template_to_html( $gallery_images[$i], $gallery_thumbs[$i], $product->get_title() );
}

echo '&lt;/div>';

function template_to_html($img, $thumb, $title) {
	$template = '&lt;a href="%s" class="" title="%s" rel="product_images[grouped]">
		&lt;img src="%s" class="attachment-shop_thumbnail size-shop_thumbnail" alt="%s" width="100" height="100">
		&lt;span class="image-overlay overlay-type-image" style="left: -1px; top: 4px; overflow: hidden; display: block; height: 120px; width: 130px;">
			&lt;span class="image-overlay-inside">&lt;/span>
		&lt;/span>
	&lt;/a>';
	
	return sprintf($template, $img, $title, $thumb, $title);
}

Accolore

Web developer, Wordpress enthusiast, father of two splendid girls.