Media
media defines the libraries used by image fields, file fields and images in rich text. Uploads are committed to the site's GitHub repository, like any other file. Each library has two paths:
input: the folder in the repository where files are stored.output: the public path the site serves them from, which is what gets written into content.
media:
input: public/uploads
output: /uploadsWith this, uploading photo.jpg stores public/uploads/photo.jpg and saves /uploads/photo.jpg in the field. The site must serve that path; SP CMS doesn't configure it. In an Astro site, files in public/ are served from the root, so public/uploads becomes /uploads. See set up a site for help finding the values.
Each upload can be up to 20 MB.
Shorthand
A string sets input, and output becomes the same path with a leading /:
media: uploads # input: uploads, output: /uploadsMultiple libraries
Use a list to give different content different folders or file types. Each library needs a unique name:
media:
- name: images
label: Images
icon: Image01
input: public/images
output: /images
categories: [image]
rename: safe
- name: documents
label: Documents
input: public/files
output: /files
categories: [document, spreadsheet]Fields use the first library unless they pick one with options.media:
- name: brochure
type: file
options:
media: documentsKeys
Without categories or extensions, a library accepts any file type.
Field settings
Image, file and rich-text fields can set their own allowed types and rename:
extensionsorcategorieson a field narrow what the library allows. They can't add a type the library doesn't accept.- Without them, an image field accepts the library's types, or image types if the library has no restriction. Images in rich text only ever accept image types.
renameon a field replaces the library's setting for uploads made from that field.
A saved image or file value must point inside its library. SP CMS rejects paths outside the library's folder, including links to other websites.