Skip to main content

Product images

Shoptet saves product images in their original size and then prepares several standardized versions (called image cuts). These cuts are created in advance and stored on the disk, so they are readily available. The list of cuts is the same for every e-shop, although each e-shop can theoretically have different cut sizes. In practice, their size is determined by the template, and most templates use the same sizes. The list of available cuts is defined by the Image Cuts code list.

The imageCuts list always also contains the orig cut, the image in its original size (its width and height are null). There is no signed CDN file name for it, so retrieve original images via urlPath + name (or seoName).

The /api/eshop?include=imageCuts Eshop info endpoint returns the imageCuts field in the response, where each cut has its actual size and two base URLs defined. Example of the detail cut:

{
"name": "detail",
"width": 360,
"height": 270,
"urlPath": "https://fenix.myshoptet.com/user/shop/detail/",
"cdnPath": "https://cdn-api.myshoptet.com/usr/fenix.myshoptet.com/user/shop/detail/"
}

For the e-shop classic.shoptet.cz, the two base URLs of the detail cut would be:

Use the urlPath if you need an up-to-date image immediately, are using the URL for backend processing, and will retrieve the images only once. Images retrieved via urlPath are not cached. You can use the image name or the SEO version of the image name — see below.

Use the cdnPath if you want to use the image URL on the frontend, where users of your application will see it — for example, if you're providing an alternative frontend, a mobile application, etc. These images are cached and served with lower latency. Use the cdnName or signedCdnNames retrieved from the product detail endpoint (or similar) — see below.

Once you have chosen the base URL based on the purpose and the image cut size (for example, detail for the product detail or related for a product preview), append the filename you need. The filename can be retrieved from the product detail endpoint.

The product detail endpoint /api/products/{guid}?include=images returns image data in data.images[] in the same order as they are entered in the administration. Append the file name name (e.g. 100.jpg) to the URL of the appropriate cut to get the full image path — for example: https://classic.shoptet.cz/user/shop/detail/100.jpg

You can also use the seoName, which contains a description of the image; you will be redirected to the same image. The cdnName is intended for use with the cdnPath only. It contains a signed file name for the big cut. For other cuts, use the signedCdnNames array: each element has a type (the cut code, e.g. big, detail, thumbnail) and a name (the pre-signed file name) that can be appended to the cdnPath of the matching cut.

The relevant fields of one item of data.images[] look like this (other fields omitted):

{
"name": "106.png",
"description": "shamrock 2115611 640",
"seoName": "106_shamrock-2115611-640.png",
"changeTime": "2018-06-20T14:00:53+0200",
"cdnName": "106_shamrock-2115611-640.png?ff=1&x=1024&y=768&q=85&ts=5b2a41f5&sg=cce48299",
"signedCdnNames": [
{"type": "big", "name": "106_shamrock-2115611-640.png?ff=1&x=1024&y=768&q=85&ts=5b2a41f5&sg=cce48299"},
{"type": "detail", "name": "106_shamrock-2115611-640.png?ff=1&x=423&y=318&q=85&ts=5b2a41f5&sg=265606b9"}
]
}

So, the valid combinations are:

  • urlPath + name
  • urlPath + seoName
  • cdnPath of the big cut + cdnName
  • cdnPath of a cut + the signedCdnNames[].name of the same type

The CDN file names contain an encoded change timestamp (ts). Whenever the image is replaced (either manually in the administration or via import), a new change timestamp is assigned and the CDN file names change accordingly. Old-format CDN URLs (with a bare hash) remain valid.

The signed query parameters (ff, x, y, q, ts, sg) are computed by Shoptet and must not be modified. In the rare case that the cut configuration is temporarily unavailable, signedCdnNames is null and cdnName contains an unsigned name – fall back to cdnName then.

One of the product images can be selected as the default image for a product variant. The selected image is found in data.variants[].image and contains the name of the image — this can be matched against the image list by the name field. If the variant has no preselected default image, the image parameter is null.

The data.items[].mainImage field in the order detail contains the main image of the order item — this is either the default variant image or, if not set (or the product has no variants), the default product image. The structure is the same as in the product detail, but only the default (representative) image is provided here. The full path can be constructed by combining the urlPath from the e-shop info with the name or seoName field provided for the order item, or the cdnPath with the cdnName / signedCdnNames in the same way as for product images.

Similarly, the product list includes data.products[].mainImage, which provides the main image of each product.