details:   https://code.tryton.org/tryton/commit/0949e352994c
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue May 27 00:08:28 2025 +0200
description:
        Add id as matching key for product image URL

        This allows to generate an URL for a specific image.
diffstat:

 modules/product_image/product.py |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r fc7691c60214 -r 0949e352994c modules/product_image/product.py
--- a/modules/product_image/product.py  Thu Aug 28 10:51:26 2025 +0200
+++ b/modules/product_image/product.py  Tue May 27 00:08:28 2025 +0200
@@ -54,6 +54,7 @@
                 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 @@
             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 @@
 
     @classmethod
     def allowed_match_keys(cls):
-        return set()
+        return {'id'}
 
     @classmethod
     def preprocess_values(cls, mode, values):

Reply via email to