From 6360869d6cc8ca863458626908483b8872ee70d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 27 May 2025 00:08:28 +0200 Subject: [PATCH] Add id as matching key for product image URL This allows to generate an URL for a specific image. --- modules/product_image/product.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/product_image/product.py b/modules/product_image/product.py index 01dee6980c..e620e5f8fc 100644 --- a/modules/product_image/product.py +++ b/modules/product_image/product.py @@ -54,6 +54,7 @@ class ImageURLMixin: width = args.pop('w', None) height = args.pop('h', None) index = args.pop('i', None) + id = args.pop('id', None) args = {k: int(bool(v)) for k, v in args.items()} if size: args['s'] = size @@ -67,6 +68,8 @@ class ImageURLMixin: args['t'] = ( base64.urlsafe_b64encode(timestamp.to_bytes(8, 'big')) .decode().rstrip('=')) + if id is not None: + args['id'] = id url += '?' + urlencode(args) return url @@ -131,7 +134,7 @@ class ImageMixin(_ImageMixin): @classmethod def allowed_match_keys(cls): - return set() + return {'id'} @classmethod def preprocess_values(cls, mode, values):