getMedia()
Gets media data by slug or ID.
Signature
const response = await window.FairShareSDK.getMedia(identifier);
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | string | Media slug or ID |
Returns
Promise<MediaResponse> — The response object containing metadata and media data.
Media Object:
| Property | Type | Description |
|---|---|---|
id | number | Media ID |
title | string | Media title |
description | string | Media description |
slug | string | URL-friendly identifier |
custom_slug | boolean | Whether slug is custom |
active | boolean | Whether media is active |
kind | string | Media kind (e.g., image, video) |
media_type | string | Type of media (e.g., share) |
media_format | string | File format (e.g., png, mp4) |
image_url | string | Thumbnail/poster image URL |
video_url | string | Video URL (for video media) |
pdf_url | string | PDF URL (for PDF media) |
powerpoint_url | string | PowerPoint URL (for presentation media) |
duration | number | Duration in seconds (for video) |
comments_count | number | Number of comments |
subtitles | object | Subtitle tracks by language |
settings | object | Media settings (CTA, SEO) |
enrollment_packs | array | Array of enrollment packs associated with the media |
products | array | Array of products attached to the media |
Example
// Get media by slug const response = await window.FairShareSDK.getMedia("welcome-video"); console.log('Title:', response.media.title); console.log('Type:', response.media.media_type); console.log('Thumbnail:', response.media.image_url); // Access products response.media.products.forEach(product => { console.log('Product:', product.title); });
Related
- Media — Media component
- getLibrary — Get library/playlist data