concrete/render/broken-image
An `<img>` renders with no source.
An <img> renders with no source.
Graded by the render stage of concrete check, in the render venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
An <img> with no source is a broken icon on a published page, and it is the ordinary
outcome of writing the tag yourself around a value that may be absent: the markup is
unconditional, the value is not. A slot has an empty state by design —
the fill may abstain, the editor starts blank — and the render stage renders exactly that
state, per slot, whether or not a fixture covers it.
Fix
Render an image slot through Slot.Image, which renders the responsive engine when there
is a value and the marked empty branch when there is not. If you are laying out a
collection row yourself, Image takes the row's value and does the same. Never emit an
<img> whose source can be empty.
Before and after
import { fact, image, Section, section } from "@homepages/concrete";
export const Hero = section(
{ key: "hero", label: "Hero", slots: { shot: image({ label: "Hero image", from: fact.property.property_media }) } },
({ slot }) => (
<Section>
{/* No value, no src — and the tag renders anyway. */}
<img src={slot.shot.present ? String(slot.shot.value) : undefined} alt="" />
</Section>
),
);import { fact, image, Section, section, Slot } from "@homepages/concrete";
export const Hero = section(
{ key: "hero", label: "Hero", slots: { shot: image({ label: "Hero image", from: fact.property.property_media }) } },
({ slot }) => (
<Section>
<Slot.Image slot={slot.shot} className="aspect-[3/2] w-full" />
</Section>
),
);