如何在BigCommerce代码中添加查询字符串?

问题描述

如何在“ image = product.main_image”指令之后的右边添加查询字符串。我只想向图像的SRC标签添加查询字符串,但不知道如何编辑BigCommerce代码。谢谢。

    {{> components/common/responsive-img
                image=product.main_image
                class="productView-image--default"
                fallback_size=theme_settings.product_size
                lazyload=theme_settings.lazyload_mode
                default_image=theme_settings.default_image_product
                otherAttributes="data-main-image"
    }}

解决方法

这里的main_image属性实际上是一个对象,其中嵌套了URL。因此,您不能直接向其中添加查询字符串。

您可以在组件本身中执行此操作,例如:

https://github.com/bigcommerce/cornerstone/blob/master/templates/components/common/responsive-img.html#L39

如果需要,可以在结果顶部调用{{setURLQueryParam}} helper来添加参数。