Skip to main content

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 to createYooptaEditor; do not pass plugins to <YooptaEditor>.
Required ConfigurationYou must configure the upload option. Without this option, you’ll see an error when trying to use the Image plugin.
See the Configuration section below for detailed examples.

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:
  1. Endpoint-based: Configure an API endpoint and the plugin handles the request
  2. 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):
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.
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

Compress and resize images before uploading to reduce load times
Provide descriptive alt text for accessibility
Configure appropriate maxWidth and maxHeight for your design
Enable lazy loading for better performance
Handle upload errors gracefully with user feedback

Hooks

useImageUpload

Supports both endpoint-based and custom function approaches:

useImageDelete

Supports both endpoint-based and custom function approaches:

Troubleshooting

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:
If you want to delete images from your storage when removed from the editor, you need to configure the delete option.Solution: Add a delete configuration to your Image plugin:
Note: The delete option is optional. Without it, images are only removed from the editor.
This error occurs when using endpoint-based configuration without providing the endpoint URL.Solution: Make sure to include the endpoint property: