Overview

Image Schema

s.image()

Images. Use s.image for the schema. The content is a plain object with a path, plus the metadata (width, height, mimeType) read off the file. Also note by adding .remote you can enable remote images.

Passing an image gallery module instead of options - s.image(galleryVal) - turns the field into a picker for that gallery. The value is then only the path: the width, height and mimeType are stored once, in the gallery, and repeating them on the field is a validation error.

Options:
accept: string

The accept value is a comma-separated list of one or more image types, or unique file type specifiers, describing which file types to allow.

s.image({ accept: "image/webp" })
Methods:
.validate: method

Custom validation function

.remote: method

Enable remote images

Examples:
Example
const schema = s.image();
export default c.define("/content/image.val.ts", schema, {
  path: "/public/val/hero.jpg", //  NOTE: the actual files must be in the public/val folder
  width: 1200,
  height: 800,
  mimeType: "image/jpeg",
  alt: "Hero image",
})
Picking from a gallery
import galleryVal from "./gallery.val"; // a s.images() module

const schema = s.image(galleryVal);
export default c.define("/content/image.val.ts", schema, {
  // Only the path: the gallery has the width, height and mimeType
  path: "/public/val/images/hero_a1b2c.png",
})