This project is still a work in progress.

payload bricks
Fields

Media

A media upload

Installation

npx shadcn@latest add https://payload-bricks.bblank.dev/r/media-field.json

Usage

example-config.ts
import { mediaField } from "@/fields/media"
import type { Block } from "payload"

export const ExampleBlock: Block = {
  slug: "example",
  interfaceName: "Example",
  fields: [
    // your other fields
    mediaField,
  ],
}
example-block.tsx
import type { Example, Media } from "@/payload-types"
import Image from "next/image"

export function ExampleBlock(props: Example) {
  const media = props.media
  if (!media) return null

  return (
    <Image
      src={media.url}
      alt={media.alt ?? ""}
      width={media.width ?? 0}
      height={media.height ?? 0}
    />
  )
}

Field structure

nametype
mediaupload

On this page