Types
The types of @poltura/theme-sdk/media.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/media';AssetRef
A reference to a file under the theme's assets/ folder, as asset() returns it.
type AssetRef = `asset://${string}`MediaFormat
An image file format a rendition can be served in.
type MediaFormat = 'webp' | 'avif' | 'jpg' | 'png' | 'svg'MediaImageRef
An image a view model carries: the stored URL plus what was measured when it was uploaded.
urlrequiredstringThe stored image URL; `MediaImage` derives every rendition from it.
altrequiredstring | nullThe alt text, or null when the image has none and the caller supplies its own.
widthnumberWidth in pixels of the original upload, when it was measured.
heightnumberHeight in pixels of the original upload, when it was measured.
hasAlphabooleanWhether the image has transparent pixels, so it can sit on any background.
lqipstringA tiny inline placeholder shown while the image loads.
mimestringThe MIME type of the original upload, such as `image/png`.
MediaRole
The rendition an image is drawn at; each role has its own size and crop.
type MediaRole = 'thumb' | 'card' | 'tile' | 'pdp' | 'zoom' | 'hero' | 'og' | 'logo' | 'icon'ResolvedMedia
A media library file or theme asset, resolved for drawing.
idrequiredstringThe file id, stable across edits.
urlrequiredstringThe URL of the stored original.
kindrequired'image' | 'video' | 'svg' | 'document'What the file is: a raster image, a video, an SVG or a document.
mimeTyperequiredstringThe MIME type of the stored original, such as `image/webp`.
widthrequirednumber | nullWidth in pixels, or null when it was not measured.
heightrequirednumber | nullHeight in pixels, or null when it was not measured.
durationMsrequirednumber | nullLength of a video in milliseconds, or null for images.
altrequiredstringThe alt text in the shopper's language; `''` marks the image decorative.
focalrequired{ readonly x: number; readonly y: number; }The point the crop keeps in view, from 0 to 1 on each axis.
lqiprequiredstring | nullA tiny inline placeholder shown while the file loads, or null.
hasAlpharequiredbooleanWhether the image has transparent pixels.
posterrequired{ readonly url: string; readonly width: number | null; readonly height: number | null; readonly lqip: string | null; } | nullThe still frame shown before a video plays, or null.
VideoValue
The value of a video setting: the source alone, or the source with how it plays.
type VideoValue = string | {
readonly src: string;
readonly poster?: string;
readonly autoplay?: boolean;
readonly loop?: boolean;
readonly muted?: boolean;
readonly alt?: string;
}MediaImageProps
Props of MediaImage.
imagerequiredMediaImageRef | MediaValueA view model's image, or a media field's value (`media://`, `asset://` or an image URL).
roleMediaRoleThe rendition to draw, which sets the size and crop of every source; omitted, the one the URL names.
altstringAlt text that overrides the image's own; empty keeps the image's own.
decorativebooleanA backdrop that carries no meaning: drawn with no alt text, whatever the image's own says.
classNamestringClasses added to the image.
sizesstringThe `sizes` attribute, so the browser picks the right width.
prioritybooleanLoads the image eagerly; reserve it for the largest image above the fold.
fieldstringThe setting id the image came from, so the customizer can point at it when it fails.
fallbackReactNodeDrawn instead of the neutral placeholder while there is no picture to show.
MediaPlaceholderProps
Props of MediaPlaceholder.
classNamestringClasses added to the placeholder.
labelstringRead out when the missing image carried meaning; without it the placeholder is decorative.
widthnumberWidth of the frame the image would fill, which sets the aspect ratio.
heightnumberHeight of the frame the image would fill, which sets the aspect ratio.
VideoSettingView
A video setting ready to draw.
kindrequired'file' | 'embed'A file the page plays itself, or a YouTube or Vimeo player.
srcrequiredstringThe file's URL, or the player's embed URL.
titlerequiredstring | nullThe player's title, for an embed; null for a file.
posterrequiredstring | nullThe still shown before it plays, or null.
autoplayrequiredbooleanWhether it starts by itself; shoppers who ask for reduced motion get it paused.
looprequiredbooleanWhether it starts over at the end.
mutedrequiredbooleanWhether it plays without sound.
altrequiredstring | nullThe text alternative, or null.
SettingVideoProps
Props of SettingVideo.
valuerequiredVideoValue | undefinedThe `video` setting's value.
coverbooleanFills a positioned parent edge to edge as a backdrop, playing muted without controls.
classNamestringClasses merged onto the video or player.