Developers
Start building
Themes/Theme SDK/Modules/media/Functions

Functions

The functions of @poltura/theme-sdk/media.

On this page
import { … } from '@poltura/theme-sdk/media';

asset

A reference to a file under the theme's assets/ folder, by its path there.

asset(path: string): AssetRef

Parameters

  • path: string: The path inside assets/, such as images/hero.jpg.

Returns: The asset:// reference that MediaImage and image settings resolve.

Example

import { MediaImage, asset } from '@poltura/theme-sdk/media';

export function Logo() {
  return <MediaImage image={asset('images/logo.png')} role='logo' alt='' />;
}

mediaUrl

The URL of one rendition of a stored image; any other URL comes back as it is.

mediaUrl(src: string, role: MediaRole): string

Parameters

  • src: string: The stored image URL.
  • role: MediaRole: The rendition to load.

Returns: The rendition's URL, or src itself when it is not a store image.

Last updated