---
title: Plan your image variant set
---

> **Documentation indexes**
> The indexes below list current page URLs with titles and descriptions. Links on this page point to the Markdown versions of the linked pages.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Image variants let Xperience by Kentico serve each image at a size and crop tailored to its layout. Defining a compact set of variants keeps images sharp on high-density screens, reduces download sizes on slower connections, and frames the subject cleanly across breakpoints.

The variants also shape content editor workflows. Editors can adjust each image's focal point, which steers the crop of every variant, and crop individual variants by hand. For the editor's side of image variants, see [Work with image variants and focal point](https://docs.kentico.com/guides/digital-marketing/xperience-essentials/work-with-image-variants-and-focal-point.md#understanding-image-variants).

By the end of this material, you'll plan a variant set from screen resolution data, create the definitions in the administration, map their code names to constants in code, and configure them for deployment across environments.

## Understand variant definitions

Each [image variant definition](https://docs.kentico.com/documentation/developers-and-admins/development/content-types.md#configure-image-variants) applies project-wide across all images in reusable content item asset fields. A definition specifies a code name, display name, dimensions, and transformation type while preserving the file format of the original image.

The asset metadata of each image lists available variants. Xperience adds the variants to the metadata when an image is uploaded, and adds new or changed definitions to the metadata of existing images through the _Update asset variants_ [system scheduled task](https://docs.kentico.com/documentation/developers-and-admins/customization/scheduled-tasks.md). Xperience generates the variant file itself on its first request. Since every requested variant creates an additional file in storage, keep your variant set focused and give each definition a distinct role in the layout.

Before you define any variants, go through the site's designs with the designers and editors of the project and identify layouts and areas where images appear and choices between crops are needed.

## Choose a variant type

Xperience supports two image variant types:

- **Scaled** – Resizes the full image while preserving its original aspect ratio. When you set the height to _0_, Xperience calculates each variant's height automatically from the source aspect ratio. Combining several Scaled variants of increasing widths gives you a width series for an HTML `srcset` [attribute](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset), allowing the browser to download the smallest file that renders sharply on the visitor's screen.

  ![Six Scaled variants of a photo of farfalle with pesto, drawn as nested frames that share the photo's top-left corner and aspect ratio, labelled 480, 828, 1280, 1600, 1920, and 2560. A bar chart beside them shows the file size of each width.](https://docs.kentico.com/docsassets/modules/plan-your-image-variant-set/Scaled_Variant_Widths.drawio.svg "Scaled variants of one photo")

- **Smart crop** – Crops the image around its focal point to match the definition's aspect ratio, then scales the result to the exact target dimensions. Use Smart crop variants for fixed-ratio image areas such as cards and thumbnails, or for hero banners that switch crops across viewports inside a `<picture>` [element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture).

  ![The original 4592 × 3064 px photo of farfalle with pesto, with its focal point marked in the centre, and three Smart crop variants of it in the image areas they serve.](https://docs.kentico.com/docsassets/modules/plan-your-image-variant-set/Smart_Crop_Image_Areas.drawio.svg "Smart crop variants in their image areas")

Use a single fixed-size variant of either type where only one file of a known size works, for example in emails, where responsive attributes are often unsupported by email clients.

## Build a width series for Scaled variants

Page layouts use [CSS pixels](https://developer.mozilla.org/en-US/docs/Glossary/CSS_pixel) for element dimensions and viewport widths. High-density displays map multiple hardware pixels to each CSS pixel according to the screen's device pixel ratio (DPR). To calculate the image width required for a given image area, multiply its rendered CSS pixel width by the screen's DPR. For example, a full-width image on a 414 CSS px phone screen at a DPR of 2 requires an 828 px file.

> **Info:** Global screen data shows the most common viewport and DPR combinations. In September 2026, [StatCounter's mobile screen statistics](https://gs.statcounter.com/screen-resolution-stats/mobile/worldwide) reported 414 × 896 as the most common mobile viewport worldwide, while [StatCounter's desktop statistics](https://gs.statcounter.com/screen-resolution-stats/desktop/worldwide) listed 1920 × 1080 for desktops. Browser telemetry from [web3dsurvey's device pixel ratio dataset](https://web3dsurvey.com/browser/values/devicePixelRatio) shows that most mobile devices operate at a DPR of 2 or 3, whereas most Windows desktops run at 1 or 1.25.

Serving assets beyond 2× density rarely improves perceived sharpness on mobile screens, as detailed in [Andrea Verlicchi's analysis on capping image fidelity at 2×](https://www.andreaverlicchi.eu/capping-image-fidelity-2x-minimize-loading-time/). In practice, a width series of four to six steps covers most layouts (see [Shopify's responsive image guidance](https://shopify.dev/docs/storefronts/themes/best-practices/performance/use-responsive-images)).

### Start from an example series

The following width series suits sites with a balanced mix of mobile and desktop traffic. Configure each entry as a Scaled variant with the height set to _0_.

| Width (px) | Intended for                                                                              |
| ---------- | ----------------------------------------------------------------------------------------- |
| 480        | Desktop cards and grid columns at 1×, or half-width mobile image areas at 2×              |
| 828        | Full-width images on 360–414 px phones at 2×                                              |
| 1280       | Full-width images on phones at 3×, or a desktop content column at 1×                      |
| 1600       | Full-width images on laptops at 1×–1.25× and tablets at 2×                                |
| 1920       | Full-width images on 1920 × 1080 desktop screens                                          |
| 2560       | 1280 px content columns on high-density laptops and full-width images on 2560 px monitors |

For sites with predominantly mobile traffic, a mobile-focused series of 360, 640, 828, 1080, 1280, and 1920 px provides finer steps at narrower widths.

> **Warning:** Xperience upscales a Scaled variant when its defined width exceeds the original image width, producing a larger file with no additional detail. When generating a `srcset`, omit any variant wider than the source image.

### Tailor the series to your audience

If you have analytics data for your site, you can derive a width series directly from your visitors' screen dimensions:

1. Export the viewport width and device pixel ratio (DPR) for your page views.
2. For each key image area in your layout, multiply its rendered CSS width by the visitor's DPR (capping the DPR at 2 if you limit fidelity to 2×).
3. Take the 50th, 75th, 90th, and 95th percentiles of the resulting pixel widths as initial candidates.
4. Merge candidate widths that fall within 20–25% of each other, keeping the larger value.
5. Test the remaining widths against several representative photos and remove any step that saves only a few kilobytes compared to the next larger variant.

## Size Smart crop variants for fixed image areas

Each Smart crop variant outputs a single fixed width and height. Sizing a crop at roughly twice its rendered CSS dimensions keeps it sharp on high-density displays while keeping file sizes reasonable. A single variant per aspect ratio is enough when an image area stays near the same CSS dimensions across breakpoints; add a second variant with the same ratio only when the area renders at substantially different sizes on mobile and desktop viewports.

The following Smart crop definitions cover common fixed-ratio image areas:

| Image area           | Size (px)   | Ratio | Target layout                                                                        |
| -------------------- | ----------- | ----- | ------------------------------------------------------------------------------------ |
| Card                 | 800 × 600   | 4:3   | 400 CSS px card at 2× density                                                        |
| Hero on phones       | 828 × 828   | 1:1   | Mobile crop for a hero banner that switches crops on 414 CSS px phones at 2× density |
| Hero on wide screens | 1920 × 1080 | 16:9  | Full-width hero banner on a 1920 × 1080 desktop viewport                             |
| Thumbnail            | 256 × 256   | 1:1   | 128 CSS px thumbnail or avatar at 2× density                                         |

## Choose code names and display names

Each variant definition has two identifiers:

- **Code name** – Identifies the variant in code and in generated variant URLs. The code name becomes read-only after you create the definition.
- **Display name** – Identifies the variant in the administration UI and remains editable at any time.

For example, the [finished branch](https://github.com/Kentico/xperience-by-kentico-training-guides/tree/finished) of the _Training guides_ repository defines the following variant set:

| Display name       | Code name           |
| ------------------ | ------------------- |
| Responsive XS      | `ScaleW480`         |
| Responsive S       | `ScaleW828`         |
| Responsive M       | `ScaleW1280`        |
| Responsive L       | `ScaleW1600`        |
| Responsive XL      | `ScaleW1920`        |
| Responsive XXL     | `ScaleW2560`        |
| Card 4:3           | `Card800x600`       |
| Hero, phones       | `HeroMobile828x828` |
| Hero, wide screens | `HeroWide1920x1080` |
| Thumbnail          | `Thumbnail256x256`  |

## Create the definitions in the administration

Because the administration derives the read-only code name from the initial **Name** value when you first save a definition, save each definition with its code name first and then change its display name:

1. In the **Content types** application, navigate to **Asset configurations** -> **Image variants**.
2. Select **Add new variant**.
3. In the **Name** field, enter the variant's code name (for example, _ScaleW828_).
4. Select the transformation type and enter the **Width** and **Height**. For Scaled variants in a width series, select _Scaled_ and set the height to _0_.
5. Repeat steps 2–4 for the remaining variants, then **Save** your changes. Xperience populates the read-only **Code name** field for each saved definition.
6. Update each **Name** field to the desired display name (for example, _Responsive S_) and **Save** again.

![The Image variants page in the Content types application, listing each definition with its name, read-only code name, type, width, and height.](https://docs.kentico.com/docsassets/modules/plan-your-image-variant-set/Image_Variants_Listing.png "Image variants page with the Training guides variant set")

When Continuous Integration is enabled, verify the serialized definitions in the `cms.standardmediadimensions` folder of the CI repository. Each definition produces an XML file named with the lowercase code name, width, and height (for example, `card800x600_800_600@<hash>.xml`).

## Keep the variant code names in one class

Centralizing variant code names in a static class prevents string typos across views, tag helpers, and widget properties. In the _Training guides_ repository, the `ImageVariants` class holds the code name constants alongside `WidthSeries`, an ordered list of the Scaled variants used to build responsive `srcset` attributes.

```csharp title="ImageVariants.cs"
using System.Collections.Generic;

namespace TrainingGuides.Web.Features.ResponsiveImages;

/// <summary>
/// Code names of the site's image variant definitions. Must match the configured code
/// names and letter case (<see cref="CMS.ContentEngine.ContentItemAsset.VariantUrls"/>
/// keys are case-sensitive).
/// </summary>
public static class ImageVariants
{
    /// <summary>Scaled variant, 480 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W480 = "ScaleW480";

    /// <summary>Scaled variant, 828 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W828 = "ScaleW828";

    /// <summary>Scaled variant, 1280 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W1280 = "ScaleW1280";

    /// <summary>Scaled variant, 1600 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W1600 = "ScaleW1600";

    /// <summary>Scaled variant, 1920 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W1920 = "ScaleW1920";

    /// <summary>Scaled variant, 2560 px wide, preserving the original aspect ratio.</summary>
    public const string SCALE_W2560 = "ScaleW2560";

    /// <summary>Smart crop variant for cards, 800 × 600 px (4:3).</summary>
    public const string CARD_800X600 = "Card800x600";

    /// <summary>Smart crop variant for mobile hero banners, 828 × 828 px (1:1).</summary>
    public const string HERO_MOBILE_828X828 = "HeroMobile828x828";

    /// <summary>Smart crop variant for wide-screen hero banners, 1920 × 1080 px (16:9).</summary>
    public const string HERO_WIDE_1920X1080 = "HeroWide1920x1080";

    /// <summary>Smart crop variant for thumbnails, 256 × 256 px (1:1).</summary>
    public const string THUMBNAIL_256X256 = "Thumbnail256x256";

    /// <summary>
    /// Scaled variant code names ordered from narrowest to widest.
    /// </summary>
    public static readonly IReadOnlyList<string> WidthSeries =
    [
        SCALE_W480,
        SCALE_W828,
        SCALE_W1280,
        SCALE_W1600,
        SCALE_W1920,
        SCALE_W2560
    ];
}
```

## Move the definitions between environments

Because image variant definitions are stored in the database, transfer them between environments using [Continuous Integration (CI)](https://docs.kentico.com/documentation/developers-and-admins/ci-cd/continuous-integration.md) and [Continuous Deployment](https://docs.kentico.com/documentation/developers-and-admins/ci-cd/continuous-deployment.md). CI serializes each definition to the `cms.standardmediadimensions` folder, and the default `repository.config` generated by the Xperience project templates already includes this object type for Continuous Deployment.

Keep the following behavior in mind when deploying definitions:

- An environment only generates variants for definitions present in its database. Deploy new variant definitions before or alongside the code that references them.
- The default Continuous Deployment configuration uses the `Create` [restore mode](https://docs.kentico.com/documentation/developers-and-admins/ci-cd/configure-ci-cd-repositories.md#configure-cd-restore-mode), which adds new definitions and leaves existing definitions untouched. Use `CreateUpdate` or `Full` if you need deployments to update modified definitions (`Full` also deletes definitions removed from the repository).
