# 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:

File: `components/sections/Hero.schema.ts`

```ts
    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](https://smoodly.io/docs/media/images-and-crops.md#quality-and-width) has the rules.

**Astro**

File: `src/sections/hero.astro`

```astro
    {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`:

| Prop | Use |
| --- | --- |
| `image` | The resolved value. |
| `aspect` | Overrides the value's ratio for this placement, such as a 21:9 header over a 3:2 card. |
| `media` | Where each named crop applies, a media query per name in order: `{ mobile: "(max-width: 767px)" }`. |
| `sizes, priority, loading` | Set sizes to what the layout gives the image, and priority on the one above the fold. |
| `quality, maxWidth` | This 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](https://smoodly.io/docs/media/images-and-crops.md#quality-and-width). |
| `class, style` | Land 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](https://smoodly.io/docs/media/images-and-crops.md) has the details.

**Next.js**

File: `components/sections/Hero.tsx`

```tsx
        {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`:

| Prop | Use |
| --- | --- |
| `image` | The resolved value. |
| `aspect` | Overrides the value's ratio for this placement, such as a 21:9 header over a 3:2 card. |
| `media` | Where each named crop applies, a media query per name in order: `{ mobile: "(max-width: 767px)" }`. |
| `sizes, priority, loading` | Set sizes to what the layout gives the image, and priority on the one above the fold. |
| `quality, maxWidth` | This 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](https://smoodly.io/docs/media/images-and-crops.md#quality-and-width). |
| `className, style` | Land 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](https://smoodly.io/docs/media/images-and-crops.md) 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.

**Astro**

`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`.

**Next.js**

`SmoodlyVideo` from `smoodly/image` renders it as a `video` element with the poster and size set, and passes every other attribute through:

File: `components/sections/Reel.tsx`

```tsx
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](https://smoodly.io/docs/media/library.md) covers uploads, limits and usage.

Next, [List and object](https://smoodly.io/docs/fields/list-and-object.md).
