Fejlesztőknek
Kezdj bele
Témák/Theme SDK/Modules/media/Types

Types

Ez az oldal még csak angolul érhető el.

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.

urlrequiredstring

The stored image URL; `MediaImage` derives every rendition from it.

altrequiredstring | null

The alt text, or null when the image has none and the caller supplies its own.

widthnumber

Width in pixels of the original upload, when it was measured.

heightnumber

Height in pixels of the original upload, when it was measured.

hasAlphaboolean

Whether the image has transparent pixels, so it can sit on any background.

lqipstring

A tiny inline placeholder shown while the image loads.

mimestring

The 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.

idrequiredstring

The file id, stable across edits.

urlrequiredstring

The URL of the stored original.

kindrequired'image' | 'video' | 'svg' | 'document'

What the file is: a raster image, a video, an SVG or a document.

mimeTyperequiredstring

The MIME type of the stored original, such as `image/webp`.

widthrequirednumber | null

Width in pixels, or null when it was not measured.

heightrequirednumber | null

Height in pixels, or null when it was not measured.

durationMsrequirednumber | null

Length of a video in milliseconds, or null for images.

altrequiredstring

The 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 | null

A tiny inline placeholder shown while the file loads, or null.

hasAlpharequiredboolean

Whether the image has transparent pixels.

posterrequired{ readonly url: string; readonly width: number | null; readonly height: number | null; readonly lqip: string | null; } | null

The 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 | MediaValue

A view model's image, or a media field's value (`media://`, `asset://` or an image URL).

roleMediaRole

The rendition to draw, which sets the size and crop of every source; omitted, the one the URL names.

altstring

Alt text that overrides the image's own; empty keeps the image's own.

decorativeboolean

A backdrop that carries no meaning: drawn with no alt text, whatever the image's own says.

classNamestring

Classes added to the image.

sizesstring

The `sizes` attribute, so the browser picks the right width.

priorityboolean

Loads the image eagerly; reserve it for the largest image above the fold.

fieldstring

The setting id the image came from, so the customizer can point at it when it fails.

fallbackReactNode

Drawn instead of the neutral placeholder while there is no picture to show.

MediaPlaceholderProps

Props of MediaPlaceholder.

classNamestring

Classes added to the placeholder.

labelstring

Read out when the missing image carried meaning; without it the placeholder is decorative.

widthnumber

Width of the frame the image would fill, which sets the aspect ratio.

heightnumber

Height 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.

srcrequiredstring

The file's URL, or the player's embed URL.

titlerequiredstring | null

The player's title, for an embed; null for a file.

posterrequiredstring | null

The still shown before it plays, or null.

autoplayrequiredboolean

Whether it starts by itself; shoppers who ask for reduced motion get it paused.

looprequiredboolean

Whether it starts over at the end.

mutedrequiredboolean

Whether it plays without sound.

altrequiredstring | null

The text alternative, or null.

SettingVideoProps

Props of SettingVideo.

valuerequiredVideoValue | undefined

The `video` setting's value.

coverboolean

Fills a positioned parent edge to edge as a backdrop, playing muted without controls.

classNamestring

Classes merged onto the video or player.

Utoljára frissítve