export type MMedia = MFile | MSourceImage | MImageVariant; export type MSourceMedia = MFile | MSourceImage; export type MImage = MSourceImage | MImageVariant; export interface MMediaBase { mediaId: string; url: string; mediaType: string; } export interface MSourceBase { isSource: true; weightB: number; originalName?: string; /** * The `attachedData` is optionally loaded. So it can be `undefined` for two reasons: if there is * no attached data in the database, or if it has not been loaded. */ attachedData?: MAttachedData; } export interface MAttachedData { [language: string]: MLocalizedAttachedData | undefined; } export interface MLocalizedAttachedData { [propName: string]: string | number | boolean | object | null | undefined; caption?: string; } export interface MImageBase { kind: "image"; rawWidth: number; rawHeight: number; /** Rendered width. This value is equals to `round(rawWidth / pixelRatio)`. */ width: number; /** Rendered height. This value is equals to `round(rawHeight / pixelRatio)`. */ height: number; } export interface MFile extends MMediaBase, MSourceBase { kind: "file"; } export interface MSourceImage extends MMediaBase, MSourceBase, MImageBase { /** Can be `undefined`, then the size is computed using the theme pixel ratio. */ pixelRatio?: number; } export interface MImageVariant extends MMediaBase, MImageBase { isSource: false; pixelRatio: number; } /** * It's a filter option. `true` means all the language, `false` (default) means that the attached * data won't be loaded. */ export type WithAttachedData = boolean | { language: string };