Overview
The Image plugin provides a complete solution for adding images to your content. It supports file uploads, URL insertion, image resizing, and various display options.Installation
Basic Usage
Pass the plugin tocreateYooptaEditor; do not pass plugins to <YooptaEditor>.
Features
- File Upload: Upload images from device
- URL Insertion: Insert images via URL
- Custom Upload Functions: Direct uploads to Cloudinary, S3, Firebase, etc.
- Image Resizing: Resize images while maintaining aspect ratio
- Size Limits: Set maximum width and height
- Object Fit: Control how images fit their container
- Image Deletion: Optional deletion handling with custom functions (if not configured, deletion only removes from editor)
- Responsive: Automatically adapts to screen size
Configuration
The Image plugin supports two approaches for upload and delete operations:- Endpoint-based: Configure an API endpoint and the plugin handles the request
- Custom function: Provide your own async function for complete control (useful for direct uploads to Cloudinary, S3, Firebase, etc.)
Endpoint-based Upload (Backend API)
Custom Upload Function (Direct to Cloud)
For direct uploads to third-party services like Cloudinary, AWS S3, or Firebase Storage, you can provide a custom async function:Custom Fetch to Your API
You can also use a custom function to call your own API with fetch:Options
upload
Can be either an object (endpoint-based) or a function (custom upload):- Endpoint Object
- Custom Function
object
delete (optional)
Can be either an object (endpoint-based) or a function (custom delete). If not provided, deleting an image block will only remove it from the editor without calling any storage deletion logic.- Endpoint Object
- Custom Function
object
object
object
Element Props
string | null
Image source URL
string | null
Alternative text for accessibility
string | null
Responsive image source set
'contain' | 'cover' | 'fill' | null
How the image should fit its container
object
Image dimensions:
{ width: number, height: number }string | null
Background color for image container
Commands
Upload Response Format
Your upload endpoint should return:Custom Rendering
Parsers
HTML Deserialization
The plugin automatically deserializes<img> tags:
HTML Serialization
Markdown Serialization
Use Cases
Blog Posts
Feature images and inline illustrations
Documentation
Screenshots and diagrams
Portfolios
Project images and galleries
Product Catalogs
Product images with descriptions
Best Practices
Optimize Before Upload
Optimize Before Upload
Compress and resize images before uploading to reduce load times
Always Add Alt Text
Always Add Alt Text
Provide descriptive alt text for accessibility
Set Size Limits
Set Size Limits
Configure appropriate maxWidth and maxHeight for your design
Use Lazy Loading
Use Lazy Loading
Enable lazy loading for better performance
Provide Fallbacks
Provide Fallbacks
Handle upload errors gracefully with user feedback
Hooks
useImageUpload
Supports both endpoint-based and custom function approaches:- Endpoint-based
- Custom Function
useImageDelete
Supports both endpoint-based and custom function approaches:- Endpoint-based
- Custom Function
Troubleshooting
Error: Upload options are not configured
Error: Upload options are not configured
This error occurs when you’re using a theme but haven’t configured the
upload option.Solution: Add an upload configuration to your Image plugin:Image not deleted from storage
Image not deleted from storage
If you want to delete images from your storage when removed from the editor, you need to configure the Note: The
delete option.Solution: Add a delete configuration to your Image plugin:delete option is optional. Without it, images are only removed from the editor.Error: Missing 'endpoint' in upload/delete options
Error: Missing 'endpoint' in upload/delete options
This error occurs when using endpoint-based configuration without providing the
endpoint URL.Solution: Make sure to include the endpoint property:Related Plugins
- Video Plugin - For video content
- File Plugin - For file attachments
- Carousel Plugin - For image galleries

