Schema for dimension presets for automatic file variant generation.
Dimensions define target sizes and quality settings for automatically generating different versions of uploaded images and videos.
Fields
name- Unique name for this dimension (e.g., "thumbnail", "medium")width- Target width in pixels (nullable = maintain aspect ratio)height- Target height in pixels (nullable = maintain aspect ratio)quality- Quality setting (1-100 for images, CRF 0-51 for videos)format- Output format override (nullable = preserve original)applies_to- What this dimension applies to: "image", "video", or "both"enabled- Whether this dimension is activeorder- Display order in admin interface
Quality Settings
Images (JPEG, WebP, PNG)
- Range: 1-100
- 85 = Good quality (default)
- 95 = High quality
- 70 = Medium quality
Videos (MP4, WebM)
- Range: 0-51 (CRF - Constant Rate Factor)
- Lower = Higher quality
- 23 = Good quality (default)
- 18 = High quality
- 28 = Medium quality
Examples
# Image thumbnail
%Dimension{
name: "thumbnail",
width: 150,
height: 150,
quality: 85,
format: "jpg",
applies_to: "image",
enabled: true,
order: 1
}
# Video 720p variant
%Dimension{
name: "720p",
width: 1280,
height: 720,
quality: 23,
format: "mp4",
applies_to: "video",
enabled: true,
order: 2
}
# Responsive image (maintain aspect ratio)
%Dimension{
name: "large",
width: 1920,
height: nil, # Maintain aspect ratio
quality: 85,
format: nil, # Preserve original
applies_to: "image",
enabled: true,
order: 3
}
Summary
Functions
Returns whether this dimension applies to images.
Returns whether this dimension applies to videos.
The standard sizes that always keep the aspect ratio.
Changeset for creating or updating a dimension.
How a fixed rendition can be cropped: around the middle, or around the subject.
Returns a human-readable description of this dimension.
The side a rendition that keeps proportions can fix: its width, or its height.
Whether dimension keeps proportions and fixes its height (the width
follows each photo: a horizontal panorama's thumbnail).
Whether dimension is cropped around the photo's focal point: a fixed box
(not one that keeps proportions) whose crop mode is focus.
Returns whether this dimension preserves aspect ratio.
Whether dimension is one of the standard sizes.
The sizes every variant set has; they cannot be renamed or deleted.
Types
@type t() :: %PhoenixKit.Modules.Storage.Dimension{ __meta__: term(), alternative_formats: [String.t()], applies_to: String.t() | nil, crop_mode: String.t(), enabled: boolean(), fit_by: String.t(), format: String.t() | nil, height: integer() | nil, inserted_at: DateTime.t() | nil, maintain_aspect_ratio: boolean(), name: String.t() | nil, order: integer(), quality: integer() | nil, updated_at: DateTime.t() | nil, uuid: UUIDv7.t() | nil, variant_set_uuid: UUIDv7.t() | nil, width: integer() | nil }
Functions
Returns whether this dimension applies to images.
Returns whether this dimension applies to videos.
The standard sizes that always keep the aspect ratio.
Changeset for creating or updating a dimension.
Required Fields
nameapplies_towidth- Required whenmaintain_aspect_ratiois true or false
Optional Fields
height- Required whenmaintain_aspect_ratiois false (fixed dimensions)maintain_aspect_ratio- Whether to preserve aspect ratio (default: true)
Validation Rules
- Name must be unique
- Width must be specified (always required)
- Height must be specified when
maintain_aspect_ratiois false - Width and height must be positive integers
- Quality must be between 1-100 for images or 0-51 for videos
- Applies to must be one of: "image", "video", "both"
- Format must be valid if specified
- Order must be >= 0
How a fixed rendition can be cropped: around the middle, or around the subject.
Returns a human-readable description of this dimension.
The side a rendition that keeps proportions can fix: its width, or its height.
Whether dimension keeps proportions and fixes its height (the width
follows each photo: a horizontal panorama's thumbnail).
Whether dimension is cropped around the photo's focal point: a fixed box
(not one that keeps proportions) whose crop mode is focus.
Returns whether this dimension preserves aspect ratio.
Whether dimension is one of the standard sizes.
The sizes every variant set has; they cannot be renamed or deleted.