Overview
Image blocks display images with support for resizing, alignment, and various image sources (URLs, local files, base64). They provide a rich image editing experience with interactive controls.Block Keys
/lib/src/editor/block_component/image_block_component/image_block_component.dart:5
Creating Image Nodes
Use theimageNode() helper function:
'left'- Left-aligned'center'- Center-aligned (default)'right'- Right-aligned
/lib/src/editor/block_component/image_block_component/image_block_component.dart:33
Component Builder
Create an image component with custom configuration:showMenu- Show menu on hover (default:false)menuBuilder- Custom menu widget builder
/lib/src/editor/block_component/image_block_component/image_block_component.dart:55
Widget Structure
/lib/src/editor/block_component/image_block_component/image_block_component.dart:95
Resizable Images
Images use theResizableImage widget:
- Drag to resize - Interactive resize handles
- Maintains aspect ratio - Automatic height calculation
- Alignment aware - Respects image alignment
- Editable control - Can be disabled in read-only mode
/lib/src/editor/block_component/image_block_component/image_block_component.dart:155
Alignment
Images support three alignment options:/lib/src/editor/block_component/image_block_component/image_block_component.dart:308
Menu on Hover
WhenshowMenu is enabled, a menu appears on hover:
/lib/src/editor/block_component/image_block_component/image_block_component.dart:197
Selection Behavior
Images support block selection:- Click to select - Entire image block
- Keyboard navigation - Arrow keys work
- Block operations - Delete, copy, cut, paste
/lib/src/editor/block_component/image_block_component/image_block_component.dart:175
Validation
Image blocks must not have delta or children:/lib/src/editor/block_component/image_block_component/image_block_component.dart:91
Using in Editor
Add image support to your editor:Inserting Images
From URL
From File Picker
From Base64 (Web)
Updating Images
Change Alignment
Resize Image
Change Image Source
Custom Image Menu
Image Upload Widget
AppFlowy Editor includes anImageUploadWidget for image uploads:
Slash Menu Integration
Loading States
Handle image loading:Image Caching
Use cached network images for better performance:Key Features
- Multiple Sources - URLs, local files, base64 data
- Resizable - Interactive drag-to-resize
- Alignment - Left, center, right alignment
- Custom Menus - Hover menus with actions
- Block Selection - Full selection support
- Aspect Ratio - Automatic aspect ratio maintenance
- Editable Control - Read-only mode support
- Keyboard Navigation - Arrow key navigation
Best Practices
- Optimize images - Compress before uploading
- Use appropriate formats - JPEG for photos, PNG for graphics
- Provide alt text - Store in node attributes for accessibility
- Handle errors - Show placeholder on load failure
- Cache images - Use caching for network images
- Set reasonable max width - Prevent oversized images
- Support dark mode - Adjust image styling if needed
Accessibility
Related
Table Blocks
Create and edit tables
Custom Blocks
Create custom block components