Image, video and file
The three media fields, the resolved values your view receives, and the components that render them.
Image
f.image() opens the media picker: drop a file to upload it, or pick one from the library. aspect names one ratio, or several the crop tool may lock to, so the component knows its box before the image loads:
image: f.image({ aspect: "4:5" }),For art direction, name a crop per shape the layout needs instead: f.image({ crops: { desktop: "16:9", mobile: "4:5" } }). Editors frame each named crop on its own, all sharing one focus point, and a crop nobody framed follows the focus point at its ratio, so most images need no second look. The first crop is the field's main crop: the resolved value's crop and aspect are the first one's, and crops holds every one by name with its crop, aspect and pixel width and height. crops and aspect are exclusive, a name is a lowercase identifier, and a name removed from the schema leaves its stored frame unread. quality and maxWidth set how this kind of image is served, such as f.image({ quality: 95 }) for a portfolio's photos; Quality and width has the rules.
{image && <Image image={image} class="hero__image" sizes="(min-width: 900px) 40vw, 100vw" priority {...m.field("image")} />}Editors pick a crop and a focus point per use under Edit, and can give this use its own alt text; otherwise the asset's own alt from the library applies. What the view receives is resolved: the URL, the dimensions, the alt and the crop. Render it with Image from smoodly/astro/components:
imageThe resolved value.aspectOverrides the value's ratio for this placement, such as a 21:9 header over a 3:2 card.mediaWhere each named crop applies, a media query per name in order: `{ mobile: "(max-width: 767px)" }`.sizes, priority, loadingSet sizes to what the layout gives the image, and priority on the one above the fold.quality, maxWidthThis placement's quality (50, 60, 75, 85, 95 or 100) and the widest cut its `srcset` lists, over the field's and the project's: [Quality and width](/docs/media/images-and-crops#quality-and-width).class, styleLand on the wrapper box, which holds the aspect ratio.data-*Land on the wrapper too, so a field mark selects the image in the canvas.The box keeps its ratio and nothing shifts as it loads. The image is plain HTML whose srcset lists the framed area cut at a fixed list of widths on Smoodly's media host, in AVIF or WebP; Images and crops has the details.
{image && <SmoodlyImage image={image} className="hero__image" sizes="(min-width: 900px) 40vw, 100vw" priority {...m.field("image")} />}Editors pick a crop and a focus point per use under Edit, and can give this use its own alt text; otherwise the asset's own alt from the library applies. What the view receives is resolved: the URL, the dimensions, the alt and the crop. Render it with SmoodlyImage from smoodly/image:
imageThe resolved value.aspectOverrides the value's ratio for this placement, such as a 21:9 header over a 3:2 card.mediaWhere each named crop applies, a media query per name in order: `{ mobile: "(max-width: 767px)" }`.sizes, priority, loadingSet sizes to what the layout gives the image, and priority on the one above the fold.quality, maxWidthThis placement's quality (50, 60, 75, 85, 95 or 100) and the widest cut its `srcset` lists, over the field's and the project's: [Quality and width](/docs/media/images-and-crops#quality-and-width).className, styleLand on the wrapper box, which holds the aspect ratio.data-*Land on the wrapper too, so a field mark selects the image in the canvas.The box keeps its ratio and nothing shifts as it loads. The image is a plain <img>, not next/image, whose srcset lists the framed area cut at a fixed list of widths on Smoodly's media host, in AVIF or WebP; Images and crops has the details.
Video and file
f.video() and f.file() use the same picker. A video resolves to its URL, dimensions and, when the library has one, a poster image.
Video from smoodly/astro/components renders it as a video element with the poster and size set, and passes every other attribute through: <Video video={video} controls muted />. A file is a link to its url.
SmoodlyVideo from smoodly/image renders it as a video element with the poster and size set, and passes every other attribute through:
import { f, smoodly, type Props } from "smoodly/react";
import { SmoodlyVideo } from "smoodly/image";
export const reelSchema = smoodly.schema.section({
name: "reel",
title: "Reel",
fields: { video: f.video(), brochure: f.file().optional() },
});
function ReelView({ video, brochure, styles }: Props<typeof reelSchema>) {
return (
<smoodly.Section styles={styles} className="reel">
<SmoodlyVideo video={video} controls muted />
{brochure && <a href={brochure.url} download={brochure.filename}>{brochure.title ?? brochure.filename}</a>}
</smoodly.Section>
);
}
export const Reel = smoodly.section(reelSchema, ReelView);A file resolves to its URL, filename, size and mime type, plus a title when the value carries one. Videos are served as uploaded, with no transcoding.
Where media lives
Uploads go to the media library, one place for the whole site, and a field stores a reference to an asset plus its own crop and alt. Replace on a field picks a different asset for that field alone, and the library shows where each asset is used. The media library covers uploads, limits and usage.
Next, List and object.