From a4639f8f4f082f5b8a665db278f9a50e7014d52a Mon Sep 17 00:00:00 2001 From: Grass Huang Date: Tue, 14 Jan 2025 13:21:39 +0800 Subject: [PATCH] Fixed the issue where an incorrect DPR query string was provided in the URL after enabling the DPR feature. --- view/frontend/web/js/gallery/gallery-mixin.js | 5 ++++- view/frontend/web/js/swatch-renderer-mixin.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/view/frontend/web/js/gallery/gallery-mixin.js b/view/frontend/web/js/gallery/gallery-mixin.js index 60902b58..40cb2341 100644 --- a/view/frontend/web/js/gallery/gallery-mixin.js +++ b/view/frontend/web/js/gallery/gallery-mixin.js @@ -22,7 +22,10 @@ define([ if (!_.has(imageObject.fastly_srcset, wdpr)) return; - imageObject.img = imageObject.fastly_srcset[wdpr]; + let imgSrc = imageObject.fastly_srcset[wdpr] || '', + imgSrcDprRegx = new RegExp("\\s" + wdpr + "x$"); + + imageObject.img = imgSrc.replace(imgSrcDprRegx, ''); }); this._super(config, element); diff --git a/view/frontend/web/js/swatch-renderer-mixin.js b/view/frontend/web/js/swatch-renderer-mixin.js index 40ff2e49..0e009a23 100644 --- a/view/frontend/web/js/swatch-renderer-mixin.js +++ b/view/frontend/web/js/swatch-renderer-mixin.js @@ -35,7 +35,10 @@ define([ if (!_.has(imageObject.fastly_srcset, wdpr)) return; - imageObject.img = imageObject.fastly_srcset[wdpr]; + let imgSrc = imageObject.fastly_srcset[wdpr] || '', + imgSrcDprRegx = new RegExp("\\s" + wdpr + "x$"); + + imageObject.img = imgSrc.replace(imgSrcDprRegx, ''); }); });