Skip to content

Commit b6a336e

Browse files
authored
docs: documents block field image aspect ratio (#14679)
Fixes #13536 Includes: - adds detailed explanation of aspect ratio container for block field images - provides code example with proper imageURL and imageAltText usage
1 parent a68423b commit b6a336e

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

docs/fields/blocks.mdx

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,62 @@ Blocks are defined as separate configs of their own.
148148
trivializes their reusability.
149149
</Banner>
150150

151-
| Option | Description |
152-
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
153-
| **`slug`** \* | Identifier for this block type. Will be saved on each block as the `blockType` property. |
154-
| **`fields`** \* | Array of fields to be stored in this block. |
155-
| **`labels`** | Customize the block labels that appear in the Admin dashboard. Auto-generated from slug if not defined. Alternatively you can use `admin.components.Label` for greater control. |
156-
| **`imageURL`** | Provide a custom image thumbnail to help editors identify this block in the Admin UI. |
157-
| **`imageAltText`** | Customize this block's image thumbnail alt text. |
158-
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
159-
| **`graphQL.singularName`** | Text to use for the GraphQL schema name. Auto-generated from slug if not defined. NOTE: this is set for deprecation, prefer `interfaceName`. |
160-
| **`dbName`** | Custom table name for this block type when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from slug if not defined. |
161-
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
151+
| Option | Description |
152+
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
153+
| **`slug`** \* | Identifier for this block type. Will be saved on each block as the `blockType` property. |
154+
| **`fields`** \* | Array of fields to be stored in this block. |
155+
| **`labels`** | Customize the block labels that appear in the Admin dashboard. Auto-generated from slug if not defined. Alternatively you can use `admin.components.Label` for greater control. |
156+
| **`imageURL`** | Provide a custom image thumbnail URL to help editors identify this block in the Admin UI. The image will be displayed in a 3:2 aspect ratio container and cropped using `object-fit: cover` if needed. [More details](#block-image-guidelines). |
157+
| **`imageAltText`** | Customize this block's image thumbnail alt text. |
158+
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
159+
| **`graphQL.singularName`** | Text to use for the GraphQL schema name. Auto-generated from slug if not defined. NOTE: this is set for deprecation, prefer `interfaceName`. |
160+
| **`dbName`** | Custom table name for this block type when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from slug if not defined. |
161+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
162+
163+
_\* An asterisk denotes that a property is required._
164+
165+
### Block Image Guidelines
166+
167+
When providing a custom thumbnail via `imageURL`, it's important to understand how images are displayed in the Admin UI to ensure they look correct.
168+
169+
**Aspect Ratio and Cropping**:
170+
171+
- The image container uses a **3:2 aspect ratio** (e.g., 480x320 pixels)
172+
- Images are scaled using `object-fit: cover`, which means:
173+
- Images that don't match 3:2 will be **cropped** to fill the container
174+
- The image maintains its aspect ratio while being scaled
175+
- Cropping is centered, removing edges as needed
176+
177+
**Display Contexts**:
178+
179+
1. **Block Selection Drawer**: Images appear as thumbnails in a responsive grid when editors add blocks
180+
2. **Lexical Editor**: Images are scaled down to 20x20px icons in menus and toolbars
181+
182+
**Recommendations**:
183+
184+
- Use images with a **3:2 aspect ratio** to avoid unwanted cropping (e.g., 480x320, 600x400, 900x600)
185+
- Keep important visual content **centered** in your image, as edges may be cropped
186+
- Provide web-optimized images (JPEG, PNG, WebP) for faster loading
187+
- Always include `imageAltText` for accessibility
188+
189+
**Example**:
190+
191+
```ts
192+
const QuoteBlock: Block = {
193+
slug: 'quote',
194+
imageURL: 'https://example.com/thumbnails/quote-block-480x320.jpg',
195+
imageAltText: 'Quote block with text and attribution',
196+
fields: [
197+
{
198+
name: 'quoteText',
199+
type: 'text',
200+
required: true,
201+
},
202+
],
203+
}
204+
```
205+
206+
If no `imageURL` is provided, a default placeholder graphic is displayed automatically.
162207

163208
### Admin Options
164209

0 commit comments

Comments
 (0)