Guides
Images
Turn image-only paragraphs into styled figures and galleries.
Use rehypeImageGallery when authors should write normal Markdown images while
the site renders polished figures and multi-image galleries.
Using Lotus
Lotus enables the image gallery
transform automatically. If your site uses
@prosefly/astro-theme-lotus, the
Markdown transform is already active.
What Authors Write
A paragraph that contains only one image becomes a styled figure.
A paragraph that contains multiple images becomes a gallery.
Standalone Astro Setup
If you are not using Lotus, add the
rehype plugin in astro.config.ts.
import { defineConfig } from 'astro/config';import { rehypeImageGallery, unified,} from '@prosefly/astro-components/markdown';
export default defineConfig({ markdown: { processor: unified({ rehypePlugins: [rehypeImageGallery], }), },});Then load the gallery CSS and runtime once in the layout that renders your Markdown.
---import '@prosefly/astro-components/markdown/image-gallery.css';---
<slot />
<script> import '@prosefly/astro-components/markdown/image-gallery.js';</script>The JavaScript adds previous and next controls for galleries generated from multiple images. Single-image figures only need the CSS.
Authoring Rules
-
Keep gallery paragraphs image-only.
Do not add prose, links, inline code, or captions to the same paragraph. Mixed content stays as normal Markdown.
-
Use helpful alt text.
The transform preserves each image element. The
alttext is still the main accessibility description for the image. -
Group images intentionally.
Put related screenshots in the same paragraph. Add a blank line before the next paragraph when a new gallery should start.
Avoid double configuration
Lotus already configures
rehypeImageGallery and loads the theme styles. Add the plugin and runtime
manually only in standalone Astro projects.
Last updated Jul 23, 2026