# `PhoenixKit.Modules.Storage.VariantNaming`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.102/lib/modules/storage/variant_naming.ex#L1)

Utilities for naming and parsing storage variant names.

Variant names follow the convention:
- Primary: `"medium"` (dimension name only)
- Alternative format: `"medium_webp"` (dimension name + format suffix)

The parser splits on the last underscore and checks whether the suffix
is a known image format. If it is, the variant is an alternative format.

# `known_formats`

Returns the list of known image format suffixes.

# `mime_type_for_format`

Returns the MIME type for a format string.

## Examples

    iex> mime_type_for_format("webp")
    "image/webp"

    iex> mime_type_for_format("avif")
    "image/avif"

# `parse_variant_name`

Parses a variant name into `{base_dimension, format}`.

## Examples

    iex> parse_variant_name("medium")
    {"medium", nil}

    iex> parse_variant_name("medium_webp")
    {"medium", "webp"}

    iex> parse_variant_name("video_thumbnail")
    {"video_thumbnail", nil}

    iex> parse_variant_name("thumbnail_avif")
    {"thumbnail", "avif"}

# `variant_name`

Builds a variant name from a base dimension name and format.

## Examples

    iex> variant_name("medium", nil)
    "medium"

    iex> variant_name("medium", "webp")
    "medium_webp"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
