Skip to Content
Strapi Page Builder 1.0 is now available 🎉

Media

import { ComponentConfig } from "@wecre8websites/strapi-page-builder-react"; import Image from "next/image"; export interface MyComponentProps { myFieldName: string; } export const MyComponentConfig: Omit<ComponentConfig<MyComponentProps, MyComponentProps>, "type"> = { fields: { myFieldName: { type: "media", mediaType: "image", label: "My Field Name", }, }, defaultProps: { myFieldName: "", }, label: "My Component", render: (props) => { return <div className="relative w-48 h-48"> {props.myFieldName ? <Image src={process.env.NEXT_PUBLIC_IMAGE_URL + props.myFieldName} layout="fill" objectFit="cover" alt="" /> : null} </div> } }

This field leverages the Strapi Upload plugin (now built in to Strapi 5) to allow the user to select an image from the media library.

Field Definition

ParameterDescriptionRequired
typetexttrue
mediaTypeThe type of media to allow. Can be audio, file, image, video, alltrue
labelThe label for the field in the editor.false

Field Appearance


Strapi Page Builder

Media Select Dialog


Strapi Page Builder
Last updated on