Assign media by fill
A slot has to hold one of the property's own assets and you want the platform to choose which.
Goal
Let a fill.pick choose the property's photos, clips, tours
and files — one asset per slot, a set per list — say what should happen when the
property holds nothing that fits, and bind a contact's image where the asset is a
person's rather than the property's.
Prerequisites
- The workspace Start leaves you with.
- AI fill for what a pick is and what the model sees of a candidate.
Steps
1. Pick one asset with fill.pick
A pick chooses from its slot's candidates, and nothing else names them. A picked
slot is bound to no fact, so its candidates are the assets of its kind in the list
its from names — its images on an image, its videos on a video, its tour
links on a tour, its stored files on a document: from: fact.property.property_media
for what shows the property, fact.property.floor_plans for its plans,
fact.property.property_documents for the documents that set out its specifics,
fact.property.uploads for everything it holds. A pick always names its from;
a media slot without one owns its asset, and nothing picks it. The candidates are
both what the model chooses from and what the user picks a replacement from:
import { fact, fill, image, tour, video } from "@homepages/concrete";
const heroImage = image({
label: "Hero image",
from: fact.property.property_media,
source: fill.pick({ brief: "The photo that best shows the front of the property." }),
});
const clip = video({ label: "Property video", from: fact.property.property_media, source: fill.pick({ brief: "The full walkthrough." }) });
const walkthrough = tour({
label: "3D tour",
from: fact.property.property_media,
source: fill.pick({ brief: "The whole-home walkthrough, not a single-room scan." }),
});The brief is the whole steer, so write it against what the model can see of a
candidate. For a document that is the filename, the file type and whatever text
was distilled out of it — name the file type when it matters, because a
spreadsheet or a slide deck carries no text at all.
A pick needs no reads to see its candidates: they are the slot's own kind and
from.
Read only what the brief judges them against.
2. Say when nothing fits
A pick judges every candidate — it belongs, it does not, or the model cannot tell — and only a candidate it is sure belongs is picked, so a pick that finds none leaves the slot empty. The brief's last sentence states the bar, so a thin set of candidates is never answered with the nearest one:
import { fact, fill, image } from "@homepages/concrete";
const mark = image({
label: "Builder mark",
from: fact.property.uploads,
source: fill.pick({
brief: "The builder's or developer's own mark among the uploads. When no upload is a builder's mark, pick nothing — never seat a photograph of the property.",
}),
});3. Bind a contact's image instead of picking it
A contact's headshot and logos are not among the property's photos, so no fill
picks them. Bind the slot to a member of the primary contact's row, a locked row() of the contacts table:
import { fact, image, row, text } from "@homepages/concrete";
const contact = row({ label: "Contact", from: fact.property.contacts, locked: true });
const contactLogo = image({ label: "Contact logo", source: contact.logo_dark });
const agentName = text.short({ label: "Agent", cap: 40, source: contact.name });A bound slot is live: it follows the contact card as it changes, where a picked
slot is the user's once filled. A bound slot takes no from — it holds
what its row's member holds, and a contact's images are the contact's own, so a slot bound to one opens no picker. For a slot that prefers the builder's uploaded
mark and shows the contact's logo when the pick came back empty, declare both —
the pick of step 2 and the bound slot here — and let the pick choose the starting
case: the uploaded mark where it is present, the contact's logo otherwise. The two
marks are different fields, so the section takes one variant computed from the pick,
each mark gated to the case that draws it; the user swaps one mark for the other by
switching the case in the section's settings
(Add a display variant).
4. Pick a set with one list fill
A pick on a list chooses a subset of the property's media — a list of images from
the photos, a list of documents from the files. The pick chooses from its item's
candidates, as every pick chooses from its holder's (AI fill), and the list's own min
and max bound the set — a
filled list always declares max
(contract/fill-verb,
contract/count-bounds):
import { fact, fill, image, list } from "@homepages/concrete";
const strip = list({
label: "Photo strip",
min: 3,
max: 8,
source: fill.pick({ brief: "The strongest set, exterior first." }),
item: image({ from: fact.property.property_media }),
});To show every photo as a tour of the home, say so in the brief — keep and order every photograph, and drop what is not one. The property's photos are what the owner uploaded, a stray wordmark or flyer included, so "every photograph of the property" is the phrase that keeps them out:
import { fact, fill, image, list } from "@homepages/concrete";
const gallery = list({
label: "Gallery",
max: 24,
source: fill.pick({
brief: "Every photograph of the property, ordered as a walk through it: approach and exterior, then the rooms, then the grounds. Drop anything that is not a photograph of the property — a logo, a floor plan, a flyer. When nothing is a photograph of the property, return none at all.",
}),
item: image({ from: fact.property.property_media }),
});A gallery that must leave out the hero's photo reads the hero's slot and says so
in its brief — reads: [Hero.slots.hero_image] and "every photograph except the
hero's".
An asset lands in at most one list, and a section's later list fills draw from what remains. That is what lets a hero, a strip and a folder of documents coexist without showing the same file three times.
5. Put the candidates on a list of objects
Where each picked asset carries more than itself — a caption, a note — the list's
item is an object() whose one media field holds the candidates, named by its
from. The list's pick decides the set out of that field's candidates: which photos, in what order, never
one twice. The field holds one picked photo per item, and every other field reads
it by its const: the caption's write puts photo in its reads, so each caption
is written against the photo its own item holds:
import { fact, fill, image, list, object, text } from "@homepages/concrete";
const photo = image({ label: "Photo", from: fact.property.property_media });
const slides = list({
label: "Slides",
min: 3,
max: 8,
source: fill.pick({ brief: "The rooms that sell this home, exterior first." }),
item: object({
label: text.short({ cap: 80, source: fill.write({ reads: [fact.property.description, photo], brief: "Name what the photo shows." }) }),
fields: { photo },
}),
});A pick is a set by default, so no photo repeats across the slides; unique: false
on the pick lifts that. Add a list slot works a
list of objects through end to end.
6. Render it and state it
import { fact, fill, image, Section, section, Slot } from "@homepages/concrete";
export const Hero = section({ key: "hero", label: "Hero", slots: {
hero_image: image({
label: "Hero image",
from: fact.property.property_media,
source: fill.pick({ brief: "The photo that best shows the front." }),
}),
} }, ({ slot }) => (
<Section>
<Slot.Image slot={slot.hero_image} className="aspect-[3/2] w-full" />
</Section>
));A filled slot is exactly what a fixture states, so write the content entry with a
media entry of the fixture's own property — that is your stand-in for the pick
(Write a fixture). A fill producing a
slot the section does not declare is
contract/produces-known-slot.
Verify
Run concrete dev and select the slot: its card carries the authored
provenance chip over the fixture's stand-in, and the picker offers the candidates
the slot's kind and from name — photos for an image picking from
fact.property.property_media, files for a document picking from fact.property.uploads. Switch to a fixture on a property with no photos and the marked-empty branch should still
render.
Then run concrete check. The render stage catches an <img> with no source
(render/broken-image) and a fixture URL naming no
file the load produced
(render/unresolved-media):
concrete check passed: 13 stages.