Skip to content

Media card

Pictures, videos and sounds a tool returns — one large, a gallery as a mosaic, or a row of thumbnails, every picture opening in a lightbox.

On this page
Open
The media card, one picture, in an aparté chat The media card, one picture, in an aparté chat

What an image model draws, or a photo search finds. A picture opens in a lightbox; a video plays in the browser’s own <video> and a sound in its <audio>; a YouTube or Vimeo page is a picture that links to it, so no player script. width and height keep the space before the picture loads, so nothing jumps when it does.

Its pictures, videos and sounds follow the chat’s image policy: one from a host the app has not allowed is not fetched, and the card shows a “Show images” button that names the host. To load your own CDN with no click, call aparteGlobalConfig.setImagePolicy(['self', 'https://cdn.example.com']) (the policy).

Open

A mosaic.

Open

A row of thumbnails with their titles.

Open

The prompt or the query, while the pictures are made or found.

bash
npm install @aparte/plugin-cards @aparte/core
ts
import { setupMediaCard } from '@aparte/plugin-cards/media';

setupMediaCard({ tool: 'generate_image' }); // an image model's { data: [{ url }] } as it is
setupMediaCard({ tool: 'search_photos', map: (result) => result.results, variant: 'gallery' });

A medium’s address must be http(s) or a path on your own site. The fields, and the readers for Unsplash, Pexels and image models, are in the guide.