gallery
Multi-image picker with per-item focal point, size, repeat, and fixed-background settings. Rows are drag-to-reorder.
Stored value
array of image objects — same shape as a single `image` value, one per gallery item.
Supports
- Media library multi-select with gallery editor
- Drag-to-reorder via dnd-kit
- Per-image focal point, size, custom width, repeat, fixed-background
- Re-selecting in the media library preserves per-item settings for kept images
Config options
helpTextstring- One-line description shown above the gallery.
Example
json
{ "id": "ctrl_screens",
"type": "gallery",
"label": "Screenshots",
"attributeKey": "screens",
"parentPanelId": "panel" }
Gotchas
Heads up
Stored value is always an array. Always check `Array.isArray(value)` before mapping — empty galleries are `[]`, not `null`.
Heads up
Each item is the full image object (url, alt, focalPoint, size, etc.), so the same renderer that handles single `image` values mostly works per-item.
Notes
Consume
export default function Screens({ attributes }) {
const items = Array.isArray(attributes.screens) ? attributes.screens : [];
if (items.length === 0) return null;
return (
<ul className="gallery">
{items.map((img) => (
<li key={img.id}>
<img src={img.url} alt={img.alt || ''} width={img.width} height={img.height} />
</li>
))}
</ul>
);
}