productImage(imageId, name, [type])
returns url to product image. Function respects prestashop Friendly URL settings.
- imageId: number - image id
- name: string - if Friendly URL is enabled, this will be the output name of image file. If Friendly URL is disabled, this parameter is ignored.
- type number - id of image type. Please see
Preferences > Imagesin your prestashop back office for list of IDs
productImage(product.imageId, product.friendlyUrl) productImage(product.imageId, 'product-'+product.id+'-'+product.friendlyUrl) productImage(product.imageId, 'img', 3)
if Friendly URL are enabled
https://www.domain.com/13/printed-summer-dress.jpg https://www.domain.com/13/product-100-printed-summer-dress.jpg https://www.domain.com/13-medium_default/img.jpg
if Friendly URL are disabled:
https://www.domain.com/img/p/1/3/13.jpg https://www.domain.com/img/p/1/3/13.jpg https://www.domain.com/img/p/1/3/13-medium_default.jpg
Image file names can help us with our SEO efforts. By default, image file names are based on
friendlyURL field of associated product, so all images of the same product will have the same suffix. Although images in PrestaShop don’t have their own friendlyURL field, they have caption / label field.
We would like to use this
legend field as image filename. It can contain any characters so we need to sanitize its value – we allow only alphanumeric characters, anything else will be replaced by dash. This field can also be empty – in that case, we want to fallback to friendlyUrl field.