Skip to main content
Strapi provides a complete media library for managing images, videos, documents, and other files. strapi2front generates typed helpers for working with media fields and uploading files.

Media Types

The generated StrapiMedia interface represents files in Strapi’s media library:
utils.ts

Single vs Multiple Media Fields

Strapi media fields can be single or multiple:
article.ts

Displaying Media

Display Images

Image Formats

Strapi automatically generates multiple sizes for images:
Small preview (typically 156x156 or 245x156)
Not all formats are generated for every image. Small images may only have a thumbnail or no formats at all. Always check if a format exists before using it.

Display Non-Image Files

Document Download

Uploading Files

strapi2front generates file upload helpers via the Strapi client.

Upload Process

File uploads in Strapi are a two-step process:
1

Upload the file

Upload file to Strapi’s media library via the upload API
2

Link to content

Use the returned file ID to link it to your content type

Generated Upload Helpers

The client includes typed file upload methods:
client.ts

Upload Examples

Upload in Forms

Browser Form Upload

components/ArticleForm.astro

React Form Upload

components/UploadForm.tsx

Update Media Fields

File Validation

Validate files before upload:
utils/validation.ts

Optimize Images

Use Strapi’s generated formats for optimal performance:
components/OptimizedImage.astro
Usage:

Next Steps

Relations

Work with related content types

Services

Learn about data fetching methods

Schemas

Validate file uploads with Zod

Types

Understand media type definitions