Home > widget-integration > CartDrawerRecommendationController > updateProductImage

CartDrawerRecommendationController.updateProductImage() method

Update the product image when variant changes. Override to customize image update behavior.

Signature:

protected updateProductImage(productItem: HTMLElement, imageUrl: string): void;

Parameters

Parameter

Type

Description

productItem

HTMLElement

The product item container element

imageUrl

string

The new image URL

Returns:

void

Example

Override to add lazy loading or custom image transformations:

protected updateProductImage(productItem: HTMLElement, imageUrl: string) {
  const img = productItem.querySelector('.boost-sd__rcu-item-image img') as HTMLImageElement;
  if (img) {
    img.loading = 'lazy';
    img.src = `${imageUrl}&width=${this.getImageWidth()}&quality=80`;
  }
}